1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
20 //------------------------------------------------------------------------
22 //------------------------------------------------------------------------
26 data = (void **)gmallocn(size, sizeof(void*));
31 GList::GList(int sizeA) {
33 data = (void **)gmallocn(size, sizeof(void*));
42 void GList::append(void *p) {
49 void GList::append(GList *list) {
52 while (length + list->length > size) {
55 for (i = 0; i < list->length; ++i) {
56 data[length++] = list->data[i];
60 void GList::insert(int i, void *p) {
65 memmove(data+i+1, data+i, (length - i) * sizeof(void *));
71 void *GList::del(int i) {
76 memmove(data+i, data+i+1, (length - i - 1) * sizeof(void *));
79 if (size - length >= ((inc > 0) ? inc : size/2)) {
85 void GList::sort(int (*cmp)(const void *obj1, const void *obj2)) {
86 qsort(data, length, sizeof(void *), cmp);
89 void GList::expand() {
90 size += (inc > 0) ? inc : size;
91 data = (void **)greallocn(data, size, sizeof(void*));
94 void GList::shrink() {
95 size -= (inc > 0) ? inc : size/2;
96 data = (void **)greallocn(data, size, sizeof(void*));