4 * Revision 1.1 2001/04/04 05:43:39 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.2 1999/03/10 16:53:32 bnv
10 * Revision 1.1 1998/07/02 17:34:50 bnv
18 /* ------------- DA_Add --------------- */
20 DA_Add( DArray
*array
, void *dat
)
24 if (array
->lastitem
==array
->allocateditems
) { /* Increase size */
25 newsize
= array
->allocateditems
+ array
->increase
;
27 array
->pdata
= REALLOC(array
->pdata
,newsize
*sizeof(void*));
29 array
->pdata
= MALLOC(newsize
*sizeof(void*),"DArray");
30 MEMSET(array
->pdata
+ array
->lastitem
, 0,
31 (newsize
-array
->lastitem
)*sizeof(void*));
32 array
->allocateditems
= newsize
;
34 pos
= array
->lastitem
; /* keep position of addition */
35 array
->pdata
[array
->lastitem
++] = dat
;
37 return pos
; /* return position */
40 /* ------------- DA_AddAtFree --------------- */
42 DA_AddAtFree( DArray
*array
, void *dat
)
46 if (array
->items
==array
->allocateditems
)
47 return DA_Add(array
,dat
);
48 else { /* search for a free position */
49 for (pos
=0; pos
<array
->lastitem
; pos
++)
50 if (array
->pdata
[pos
]==NULL
)
52 array
->pdata
[pos
] = dat
;
53 if (pos
==array
->lastitem
)
60 /* ---------------- DA_Del ------------------ */
62 DA_Del( DArray
*array
, long it
)
64 if (array
->pdata
[it
]) {
66 if (it
==array
->lastitem
-1)