home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / SHMOD10.LHA / ShowModule / Modules / Pmodules / Plist / p_CleanList.e < prev    next >
Encoding:
Text File  |  1994-05-27  |  1.8 KB  |  53 lines

  1. PROC p_CleanList(ptr_list:PTR TO lh,doit,dat:PTR TO LONG,mode) /*"p_CleanList(ptr_list:PTR TO lh,doit,dat:PTR TO LONG,mode)"*/
  2. /*===============================================================================
  3.  = Para         : Address of a List,if doit<>0 free data,the data,just clean or clean and remove.
  4.  = Return       : Address of clean list.
  5.  = Description  : Remove all nodes in the list.
  6.  ==============================================================================*/
  7.     DEF c_node:PTR TO ln
  8.     DEF p=0,pivadr
  9.     DEF rdat:PTR TO LONG
  10.     c_node:=ptr_list.head
  11.     rdat:=dat
  12.     WHILE c_node
  13.         p:=0
  14.         rdat:=dat
  15.         IF c_node.succ<>0
  16.             IF doit<>0
  17.                 REPEAT
  18.                     p:=rdat[]++
  19.                     IF p<>DISE
  20.                         IF ((p<>DISE) AND (p<>DISP) AND (p<>DISL))
  21.                             pivadr:=Long(c_node+p)
  22.                         ENDIF
  23.                         IF (p=DISP)
  24.                             IF pivadr THEN Dispose(pivadr)
  25.                         ENDIF
  26.                         IF (p=DISL)
  27.                             IF pivadr THEN DisposeLink(pivadr)
  28.                         ENDIF
  29.                     ENDIF
  30.                 UNTIL (p=DISE)
  31.                 IF c_node THEN Dispose(c_node)
  32.             ENDIF
  33.             IF c_node.name THEN DisposeLink(c_node.name)
  34.             IF c_node.succ=0 THEN RemTail(ptr_list)
  35.             IF c_node.pred=0 THEN RemHead(ptr_list)
  36.             IF (c_node.succ<>0) AND (c_node.pred<>0) THEN Remove(c_node)
  37.         ENDIF
  38.         c_node:=c_node.succ
  39.     ENDWHILE
  40.     IF mode=LIST_CLEAN
  41.         ptr_list.tail:=0
  42.         ptr_list.head:=ptr_list.tail
  43.         ptr_list.tailpred:=ptr_list.head
  44.         ptr_list.type:=0
  45.         ptr_list.pad:=0
  46.         RETURN ptr_list
  47.     ELSEIF mode=LIST_REMOVE
  48.         IF ptr_list THEN Dispose(ptr_list)
  49.         RETURN NIL
  50.     ENDIF
  51. ENDPROC
  52.  
  53.