//
// GList.cc
//
-// Copyright 2001-2002 Glyph & Cog, LLC
+// Copyright 2001-2003 Glyph & Cog, LLC
//
//========================================================================
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
-#include <aconf.h>
+#include <stdlib.h>
#include <string.h>
#include "gmem.h"
#include "GList.h"
GList::GList() {
size = 8;
- data = (void **)gmalloc(size * sizeof(void*));
+ data = (void **)gmallocn(size, sizeof(void*));
length = 0;
inc = 0;
}
GList::GList(int sizeA) {
size = sizeA;
- data = (void **)gmalloc(size * sizeof(void*));
+ data = (void **)gmallocn(size, sizeof(void*));
length = 0;
inc = 0;
}
return p;
}
+void GList::sort(int (*cmp)(const void *obj1, const void *obj2)) {
+ qsort(data, length, sizeof(void *), cmp);
+}
+
void GList::expand() {
size += (inc > 0) ? inc : size;
- data = (void **)grealloc(data, size * sizeof(void*));
+ data = (void **)greallocn(data, size, sizeof(void*));
}
void GList::shrink() {
size -= (inc > 0) ? inc : size/2;
- data = (void **)grealloc(data, size * sizeof(void*));
+ data = (void **)greallocn(data, size, sizeof(void*));
}