3 Part of the swftools package.
5 Copyright (c) 2001,2002,2003,2004 Matthias Kramm <kramm@quiss.org>
7 This program is rfx_free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the rfx_free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the rfx_free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
31 // ------------------------------- malloc, alloc routines ---------------------
34 char* strdup_n(const char*str, int size)
36 char*m = (char*)rfx_alloc(size+1);
42 char*qstrdup(const char*string)
44 return strdup(string);
46 char*qstrndup(const char*string, int len)
48 return strdup_n(string, len);
51 // ------------------------------- mem_t --------------------------------------
53 void mem_init(mem_t*mem)
55 memset(mem, 0, sizeof(mem_t));
57 void mem_clear(mem_t*mem)
59 rfx_free(mem->buffer);mem->buffer = 0;
61 void mem_destroy(mem_t*mem)
66 static int mem_put_(mem_t*m,const void*data, int length, int null)
69 m->pos += length + (null?1:0);
71 m->len = (m->pos+63)&~63;
72 m->buffer = m->buffer?(char*)rfx_realloc(m->buffer,m->len):(char*)rfx_alloc(m->len);
74 assert(n+length <= m->len);
75 memcpy(&m->buffer[n], data, length);
77 m->buffer[n + length] = 0;
80 int mem_put(mem_t*m,void*data, int length)
82 return mem_put_(m, data, length, 0);
84 int mem_putstring(mem_t*m,string_t str)
86 return mem_put_(m, str.str, str.len, 1);
89 // ------------------------------- ringbuffer_t -------------------------------
91 typedef struct _ringbuffer_internal_t
97 } ringbuffer_internal_t;
99 void ringbuffer_init(ringbuffer_t*r)
101 ringbuffer_internal_t*i = (ringbuffer_internal_t*)rfx_calloc(sizeof(ringbuffer_internal_t));
102 memset(r, 0, sizeof(ringbuffer_t));
104 i->buffer = (unsigned char*)rfx_alloc(1024);
105 i->buffersize = 1024;
107 int ringbuffer_read(ringbuffer_t*r, void*buf, int len)
109 unsigned char* data = (unsigned char*)buf;
110 ringbuffer_internal_t*i = (ringbuffer_internal_t*)r->internal;
111 if(r->available < len)
115 if(i->readpos + len > i->buffersize) {
116 int read1 = i->buffersize-i->readpos;
117 memcpy(data, &i->buffer[i->readpos], read1);
118 memcpy(&data[read1], &i->buffer[0], len - read1);
119 i->readpos = len - read1;
121 memcpy(data, &i->buffer[i->readpos], len);
123 i->readpos %= i->buffersize;
128 void ringbuffer_put(ringbuffer_t*r, void*buf, int len)
130 unsigned char* data = (unsigned char*)buf;
131 ringbuffer_internal_t*i = (ringbuffer_internal_t*)r->internal;
133 if(i->buffersize - r->available < len)
136 int newbuffersize = i->buffersize;
137 int oldavailable = r->available;
138 newbuffersize*=3;newbuffersize/=2; /*grow at least by 50% each time */
140 if(newbuffersize < r->available + len)
141 newbuffersize = r->available + len + 1024;
143 buf2 = (unsigned char*)rfx_alloc(newbuffersize);
144 ringbuffer_read(r, buf2, r->available);
147 i->buffersize = newbuffersize;
149 i->writepos = oldavailable;
150 r->available = oldavailable;
152 if(i->writepos + len > i->buffersize) {
153 int read1 = i->buffersize-i->writepos;
154 memcpy(&i->buffer[i->writepos], data, read1);
155 memcpy(&i->buffer[0], &data[read1], len - read1);
156 i->writepos = len - read1;
158 memcpy(&i->buffer[i->writepos], data, len);
160 i->writepos %= i->buffersize;
164 void ringbuffer_clear(ringbuffer_t*r)
166 ringbuffer_internal_t*i = (ringbuffer_internal_t*)r->internal;
167 rfx_free(i->buffer);i->buffer = 0;
171 // ------------------------------- heap_t -------------------------------
173 void heap_init(heap_t*h,int n,int elem_size, int(*compare)(const void *, const void *))
175 memset(h, 0, sizeof(heap_t));
178 h->elem_size = elem_size;
179 h->compare = compare;
180 h->elements = (void**)rfx_calloc(n*sizeof(void*));
181 h->data = (char*)rfx_calloc(h->max_size*h->elem_size);
183 void heap_clear(heap_t*h)
185 rfx_free(h->elements);
189 #define HEAP_NODE_SMALLER(h,node1,node2) ((h)->compare((node1),(node2))>0)
191 static void up(heap_t*h, int node)
193 void*node_p = h->elements[node];
199 h->elements[node] = h->elements[parent];
200 } while(HEAP_NODE_SMALLER(h,h->elements[parent], node_p));
202 h->elements[node] = node_p;
204 static void down(heap_t*h, int node)
206 void*node_p = h->elements[node];
211 /* determine new child's position */
215 if(child+1 < h->size && HEAP_NODE_SMALLER(h,h->elements[child],h->elements[child+1])) // search for bigger child
218 h->elements[node] = h->elements[child];
219 } while(HEAP_NODE_SMALLER(h,node_p, h->elements[child]));
221 h->elements[node] = node_p;
223 void heap_put(heap_t*h, void*e)
226 memcpy(&h->data[pos*h->elem_size],e,h->elem_size);
227 h->elements[pos] = &h->data[pos];
230 int heap_size(heap_t*h)
234 void* heap_max(heap_t*h)
236 return h->elements[0];
238 void* heap_chopmax(heap_t*h)
240 void*p = h->elements[0];
241 h->elements[0] = h->elements[--h->size];
245 void heap_dump(heap_t*h, FILE*fi)
248 for(t=0;t<h->size;t++) {
250 for(s=0;s<=t;s=(s+1)*2-1) {
251 if(s==t) fprintf(fi,"\n");
253 //fprintf(fi,"%d ", h->elements[t]->x); //?
256 void** heap_flatten(heap_t*h)
258 void**nodes = (void**)rfx_alloc(h->size*sizeof(void*));
262 /*printf("Heap Size: %d\n", h->size);
263 heap_print(stdout, h);
265 *p++ = heap_chopmax(h);
270 // ------------------------------- crc32 --------------------------------------
271 static unsigned int*crc32 = 0;
272 static void crc32_init(void)
277 crc32= (unsigned int*)rfx_alloc(sizeof(unsigned int)*256);
278 for(t=0; t<256; t++) {
281 for (s = 0; s < 8; s++) {
282 c = (0xedb88320L*(c&1)) ^ (c >> 1);
287 // ------------------------------- string_t -----------------------------------
289 void string_set2(string_t*str, const char*text, int len)
294 void string_set(string_t*str, const char*text)
297 str->len = strlen(text);
303 string_t string_new(const char*text, int len)
310 string_t string_new2(const char*text)
314 s.len = strlen(text);
321 string_t* string_new3(const char*text, int len)
324 string_t*s = malloc(sizeof(string_t));
329 string_t*s = malloc(sizeof(string_t)+len+1);
331 s->str = (const char*)(s+1);
332 memcpy((char*)s->str, text, len);
333 ((char*)s->str)[len]=0;
337 string_t* string_new4(const char*text)
339 int l = strlen(text);
340 return string_new3(text, l);
343 void string_free(string_t*s)
348 if((string_t*)(s->str) == s+1) {
352 rfx_free((char*)(s->str));
357 char* string_cstr(string_t*str)
359 return strdup_n(str->str, str->len);
361 char* string_escape(string_t*str)
365 for(t=0;t<str->len;t++) {
371 char*s = malloc(len+1);
373 for(t=0;t<str->len;t++) {
374 if(str->str[t]<0x20) {
376 unsigned char c = str->str[t];
377 *p++ = "0123456789abcdef"[c>>4];
378 *p++ = "0123456789abcdef"[c&0x0f];
384 assert(p == &s[len+1]);
388 unsigned int crc32_add_byte(unsigned int checksum, unsigned char b)
392 return checksum>>8 ^ crc32[(b^checksum)&0xff];
394 unsigned int crc32_add_string(unsigned int checksum, const char*s)
401 checksum = checksum>>8 ^ crc32[(*s^checksum)&0xff];
407 unsigned int string_hash(const string_t*str)
410 unsigned int checksum = 0;
413 for(t=0;t<str->len;t++) {
414 checksum = checksum>>8 ^ crc32[(str->str[t]^checksum)&0xff];
418 unsigned int string_hash2(const char*str)
420 unsigned int checksum = 0;
425 checksum = checksum>>8 ^ crc32[(*p^checksum)&0xff];
430 unsigned int string_hash3(const char*str, int len)
435 return string_hash(&s);
437 void string_dup2(string_t*str, const char*text, int len)
440 str->str = strdup_n(text, len);
442 void string_dup(string_t*str, const char*text)
444 str->len = strlen(text);
445 str->str = strdup(text);
447 int string_equals(string_t*str, const char*text)
449 int l = strlen(text);
450 if(str->len == l && !memcmp(str->str, text, l))
454 int string_equals2(string_t*str, string_t*str2)
456 if(str->len == str2->len && !memcmp(str->str, str2->str, str->len))
461 // ------------------------------- stringarray_t ------------------------------
463 typedef struct _stringlist {
465 struct _stringlist*next;
468 typedef struct _stringarray_internal_t
474 } stringarray_internal_t;
476 void stringarray_init(stringarray_t*sa, int hashsize)
478 stringarray_internal_t*s;
480 sa->internal = (stringarray_internal_t*)rfx_calloc(sizeof(stringarray_internal_t));
481 s = (stringarray_internal_t*)sa->internal;
483 s->hash = rfx_calloc(sizeof(stringlist_t*)*hashsize);
484 s->hashsize = hashsize;
486 void stringarray_put(stringarray_t*sa, string_t str)
488 stringarray_internal_t*s = (stringarray_internal_t*)sa->internal;
490 int hash = string_hash(&str) % s->hashsize;
492 char*ss = string_cstr(&str);
493 mem_put(&s->pos, &ss, sizeof(char*));
495 stringlist_t*l = rfx_alloc(sizeof(stringlist_t));
497 l->next = s->hash[hash];
502 char* stringarray_at(stringarray_t*sa, int pos)
504 stringarray_internal_t*s = (stringarray_internal_t*)sa->internal;
506 if(pos<0 || pos>=s->num)
508 p = *(char**)&s->pos.buffer[pos*sizeof(char*)];
513 string_t stringarray_at2(stringarray_t*sa, int pos)
516 s.str = stringarray_at(sa, pos);
517 s.len = s.str?strlen(s.str):0;
520 static stringlist_t* stringlist_del(stringarray_t*sa, stringlist_t*l, int index)
523 stringlist_t*old = l;
525 if(index==l->index) {
527 memset(l, 0, sizeof(stringlist_t));
537 fprintf(stderr, "Internal error: did not find string %d in hash\n", index);
541 void stringarray_del(stringarray_t*sa, int pos)
543 stringarray_internal_t*s = (stringarray_internal_t*)sa->internal;
544 string_t str = stringarray_at2(sa, pos);
545 int hash = string_hash(&str) % s->hashsize;
546 s->hash[hash] = stringlist_del(sa, s->hash[hash], pos);
547 *(char**)&s->pos.buffer[pos*sizeof(char*)] = 0;
549 int stringarray_find(stringarray_t*sa, string_t* str)
551 stringarray_internal_t*s = (stringarray_internal_t*)sa->internal;
552 int hash = string_hash(str) % s->hashsize;
554 stringlist_t*l = s->hash[hash];
557 string_t s = stringarray_at2(sa, l->index);
558 if(string_equals2(str, &s)) {
565 void stringarray_clear(stringarray_t*sa)
567 stringarray_internal_t*s = (stringarray_internal_t*)sa->internal;
570 for(t=0;t<s->hashsize;t++) {
571 stringlist_t*l = s->hash[t];
573 stringlist_t*next = l->next;
574 memset(l, 0, sizeof(stringlist_t));
579 rfx_free(s->hash);s->hash=0;
582 void stringarray_destroy(stringarray_t*sa)
584 stringarray_clear(sa);
588 // ------------------------------- type_t -------------------------------
590 char ptr_equals(const void*o1, const void*o2)
594 unsigned int ptr_hash(const void*o)
596 return string_hash3(o, sizeof(o));
598 void* ptr_dup(const void*o)
602 void ptr_free(void*o)
607 char charptr_equals(const void*o1, const void*o2)
611 return !strcmp(o1,o2);
613 unsigned int charptr_hash(const void*o)
617 return string_hash2(o);
619 void* charptr_dup(const void*o)
625 void charptr_free(void*o)
632 char stringstruct_equals(const void*o1, const void*o2)
636 string_t*s1 = (string_t*)o1;
637 string_t*s2 = (string_t*)o2;
638 int l = s1->len<s2->len?s1->len:s2->len;
639 int r = memcmp(s1->str, s2->str, l);
643 return s1->len==s2->len;
645 unsigned int stringstruct_hash(const void*o)
648 return string_hash(o);
650 string_t*string_dup3(string_t*o)
654 string_t*s = malloc(sizeof(string_t));
659 string_t*s = rfx_alloc(sizeof(string_t)+o->len+1);
661 s->str = (const char*)(s+1);
662 memcpy((char*)s->str, o->str, s->len);
663 ((char*)s->str)[s->len]=0;
666 void stringstruct_free(void*o)
679 type_t charptr_type = {
680 equals: charptr_equals,
686 type_t stringstruct_type = {
687 equals: stringstruct_equals,
688 hash: stringstruct_hash,
689 dup: (dup_func)string_dup3,
690 free: stringstruct_free,
693 // ------------------------------- dictionary_t -------------------------------
695 #define INITIAL_SIZE 1
697 static int max(int x, int y) {
703 dict_t*d = rfx_alloc(sizeof(dict_t));
704 dict_init(d, INITIAL_SIZE);
707 dict_t*dict_new2(type_t*t)
709 dict_t*d = rfx_alloc(sizeof(dict_t));
710 dict_init(d, INITIAL_SIZE);
714 void dict_init(dict_t*h, int size)
716 memset(h, 0, sizeof(dict_t));
718 h->slots = h->hashsize?(dictentry_t**)rfx_calloc(sizeof(dictentry_t*)*h->hashsize):0;
720 h->key_type = &charptr_type;
723 dict_t*dict_clone(dict_t*o)
725 dict_t*h = rfx_alloc(sizeof(dict_t));
726 memcpy(h, o, sizeof(dict_t));
727 h->slots = h->hashsize?(dictentry_t**)rfx_calloc(sizeof(dictentry_t*)*h->hashsize):0;
729 for(t=0;t<o->hashsize;t++) {
730 dictentry_t*e = o->slots[t];
732 dictentry_t*n = (dictentry_t*)rfx_alloc(sizeof(dictentry_t));
733 memcpy(n, e, sizeof(dictentry_t));
734 n->key = h->key_type->dup(e->key);
736 n->next = h->slots[t];
744 static void dict_expand(dict_t*h, int newlen)
746 assert(h->hashsize < newlen);
747 dictentry_t**newslots = (dictentry_t**)rfx_calloc(sizeof(dictentry_t*)*newlen);
749 for(t=0;t<h->hashsize;t++) {
750 dictentry_t*e = h->slots[t];
752 dictentry_t*next = e->next;
753 unsigned int newhash = e->hash%newlen;
754 e->next = newslots[newhash];
755 newslots[newhash] = e;
762 h->hashsize = newlen;
765 dictentry_t* dict_put(dict_t*h, const void*key, void* data)
767 unsigned int hash = h->key_type->hash(key);
768 dictentry_t*e = (dictentry_t*)rfx_alloc(sizeof(dictentry_t));
769 unsigned int hash2 = hash % h->hashsize;
771 e->key = h->key_type->dup(key);
772 e->hash = hash; //for resizing
773 e->next = h->slots[hash2];
779 void dict_put2(dict_t*h, const char*s, void*data)
781 assert(h->key_type == &charptr_type);
782 dict_put(h, s, data);
784 void dict_dump(dict_t*h, FILE*fi, const char*prefix)
787 for(t=0;t<h->hashsize;t++) {
788 dictentry_t*e = h->slots[t];
790 if(h->key_type!=&charptr_type) {
791 fprintf(fi, "%s%08x=%08x\n", prefix, e->key, e->data);
793 fprintf(fi, "%s%s=%08x\n", prefix, e->key, e->data);
800 int dict_count(dict_t*h)
805 static inline dictentry_t* dict_do_lookup(dict_t*h, const void*key)
811 unsigned int ohash = h->key_type->hash(key);
812 unsigned int hash = ohash % h->hashsize;
814 /* check first entry for match */
815 dictentry_t*e = h->slots[hash];
816 if(e && h->key_type->equals(e->key, key)) {
822 /* if dict is 2/3 filled, double the size. Do
823 this the first time we have to actually iterate
824 through a slot to find our data */
825 if(e && h->num*3 >= h->hashsize*2) {
826 int newsize = h->hashsize;
827 while(h->num*3 >= newsize*2) {
828 newsize = newsize<15?15:(newsize+1)*2-1;
830 dict_expand(h, newsize);
831 hash = ohash % h->hashsize;
833 if(e && h->key_type->equals(e->key, key)) {
834 // omit move to front
841 /* check subsequent entries for a match */
842 dictentry_t*last = h->slots[hash];
844 if(h->key_type->equals(e->key, key)) {
845 /* move to front- makes a difference of about 10% in most applications */
846 last->next = e->next;
847 e->next = h->slots[hash];
856 void* dict_lookup(dict_t*h, const void*key)
858 dictentry_t*e = dict_do_lookup(h, key);
863 char dict_contains(dict_t*h, const void*key)
865 dictentry_t*e = dict_do_lookup(h, key);
869 char dict_del(dict_t*h, const void*key)
873 unsigned int hash = h->key_type->hash(key) % h->hashsize;
874 dictentry_t*head = h->slots[hash];
875 dictentry_t*e = head, *prev=0;
877 if(h->key_type->equals(e->key, key)) {
878 dictentry_t*next = e->next;
879 rfx_free((void*)e->key);
880 memset(e, 0, sizeof(dictentry_t));
897 dictentry_t* dict_get_slot(dict_t*h, const void*key)
901 unsigned int ohash = h->key_type->hash(key);
902 unsigned int hash = ohash % h->hashsize;
903 return h->slots[hash];
906 void dict_foreach_keyvalue(dict_t*h, void (*runFunction)(void*data, const void*key, void*val), void*data)
909 for(t=0;t<h->hashsize;t++) {
910 dictentry_t*e = h->slots[t];
912 dictentry_t*next = e->next;
914 runFunction(data, e->key, e->data);
920 void dict_foreach_value(dict_t*h, void (*runFunction)(void*))
923 for(t=0;t<h->hashsize;t++) {
924 dictentry_t*e = h->slots[t];
926 dictentry_t*next = e->next;
928 runFunction(e->data);
935 void dict_free_all(dict_t*h, void (*freeFunction)(void*))
938 for(t=0;t<h->hashsize;t++) {
939 dictentry_t*e = h->slots[t];
941 dictentry_t*next = e->next;
942 h->key_type->free(e->key);
944 freeFunction(e->data);
946 memset(e, 0, sizeof(dictentry_t));
953 memset(h, 0, sizeof(dict_t));
956 void dict_clear(dict_t*h)
961 void dict_destroy(dict_t*dict)
967 // ------------------------------- map_t --------------------------------------
969 typedef struct _map_internal_t
974 void map_init(map_t*map)
977 map->internal = (map_internal_t*)rfx_calloc(sizeof(map_internal_t));
978 m = (map_internal_t*)map->internal;
979 dict_init(&m->d, INITIAL_SIZE);
981 void map_put(map_t*map, string_t t1, string_t t2)
983 map_internal_t*m = (map_internal_t*)map->internal;
985 char* s1 = string_cstr(&t1);
986 dict_put2(&m->d, s1, (void*)string_cstr(&t2));
989 const char* map_lookup(map_t*map, const char*name)
991 map_internal_t*m = (map_internal_t*)map->internal;
992 const char*value = dict_lookup(&m->d, name);
995 static void freestring(void*data)
999 static void dumpmapentry(void*data, const void*key, void*value)
1001 FILE*fi = (FILE*)data;
1002 fprintf(fi, "%s=%s\n", key, (char*)value);
1004 void map_dump(map_t*map, FILE*fi, const char*prefix)
1007 map_internal_t*m = (map_internal_t*)map->internal;
1008 dict_foreach_keyvalue(&m->d, dumpmapentry, fi);
1010 void map_clear(map_t*map)
1012 map_internal_t*m = (map_internal_t*)map->internal;
1013 dict_free_all(&m->d, freestring);
1016 void map_destroy(map_t*map)
1022 // ------------------------------- array_t --------------------------------------
1024 array_t* array_new() {
1025 array_t*d = malloc(sizeof(array_t));
1026 memset(d, 0, sizeof(array_t));
1027 d->entry2pos = dict_new();
1030 array_t* array_new2(type_t*type) {
1031 array_t*d = malloc(sizeof(array_t));
1032 memset(d, 0, sizeof(array_t));
1033 d->entry2pos = dict_new2(type);
1036 void*array_getkey(array_t*array, int nr) {
1037 if(nr > array->num || nr<0) {
1038 printf("error: reference to element %d in array[%d]\n", nr, array->num);
1042 return array->d[nr].name;
1044 void*array_getvalue(array_t*array, int nr) {
1045 if(nr > array->num || nr<0) {
1046 printf("error: reference to element %d in array[%d]\n", nr, array->num);
1050 return array->d[nr].data;
1052 int array_append(array_t*array, const void*name, void*data) {
1053 while(array->size <= array->num) {
1056 array->d = malloc(sizeof(array_entry_t)*array->size);
1058 array->d = realloc(array->d, sizeof(array_entry_t)*array->size);
1062 dictentry_t*e = dict_put(array->entry2pos, name, (void*)(ptroff_t)(array->num+1));
1065 array->d[array->num].name = e->key;
1067 array->d[array->num].name = 0;
1069 array->d[array->num].data = (void*)data;
1070 return array->num++;
1072 int array_find(array_t*array, const void*name)
1074 int pos = (int)(ptroff_t)dict_lookup(array->entry2pos, name);
1077 int array_find2(array_t*array, const void*name, void*data)
1079 dict_t*h= array->entry2pos;
1080 dictentry_t*e = dict_get_slot(array->entry2pos, name);
1083 int index = ((int)(ptroff_t)e->data) - 1;
1084 if(h->key_type->equals(e->key, name) && array->d[index].data == data) {
1091 int array_update(array_t*array, const void*name, void*data) {
1092 int pos = array_find(array, name);
1094 array->d[pos].data = data;
1097 return array_append(array, name, data);
1099 int array_append_if_new(array_t*array, const void*name, void*data) {
1100 int pos = array_find(array, name);
1103 return array_append(array, name, data);
1105 void array_free(array_t*array) {
1106 dict_destroy(array->entry2pos);
1108 free(array->d);array->d = 0;
1113 // ------------------------------- list_t --------------------------------------
1116 typedef struct _listinfo {
1118 struct _commonlist*last;
1121 typedef struct _commonlist {
1123 struct _commonlist*next;
1127 int list_length_(void*_list)
1129 commonlist_t*l = (commonlist_t*)_list;
1132 return l->info[0].size;
1134 void list_concat_(void*_l1, void*_l2)
1136 commonlist_t**l1 = (commonlist_t**)_l1;
1137 commonlist_t**l2 = (commonlist_t**)_l2;
1142 (*l1)->info[0].last->next = *l2;
1143 (*l1)->info[0].last = (*l2)->info[0].last;
1144 (*l1)->info[0].size += (*l2)->info[0].size;
1148 void list_append_(void*_list, void*entry)
1150 commonlist_t**list = (commonlist_t**)_list;
1151 commonlist_t* n = 0;
1153 n = (commonlist_t*)malloc(sizeof(commonlist_t)+sizeof(listinfo_t));
1155 (*list)->info[0].size = 0;
1157 n = malloc(sizeof(commonlist_t));
1158 (*list)->info[0].last->next = n;
1162 (*list)->info[0].last = n;
1163 (*list)->info[0].size++;
1165 /* notice: prepending uses slighly more space than appending */
1166 void list_prepend_(void*_list, void*entry)
1168 commonlist_t**list = (commonlist_t**)_list;
1169 commonlist_t* n = (commonlist_t*)malloc(sizeof(commonlist_t)+sizeof(listinfo_t));
1171 commonlist_t* last = 0;
1173 last = (*list)->info[0].last;
1174 size = (*list)->info[0].size;
1179 (*list)->info[0].last = last;
1180 (*list)->info[0].size = size+1;
1182 void list_free_(void*_list)
1184 commonlist_t**list = (commonlist_t**)_list;
1185 commonlist_t*l = *list;
1187 commonlist_t*next = l->next;
1193 void*list_clone_(void*_list)
1195 commonlist_t*l = *(commonlist_t**)_list;
1199 commonlist_t*next = l->next;
1200 list_append_(&dest, l->entry);