31 |
|
|
32 |
#include <stdarg.h> |
#include <stdarg.h> |
33 |
#include <utilities/ascConfig.h> |
#include <utilities/ascConfig.h> |
34 |
|
#include <utilities/error.h> |
35 |
#include <utilities/ascPanic.h> |
#include <utilities/ascPanic.h> |
36 |
#include <utilities/ascMalloc.h> |
#include <utilities/ascMalloc.h> |
37 |
#include "list.h" |
#include "list.h" |
58 |
* just before assertion acts to handle the range error. |
* just before assertion acts to handle the range error. |
59 |
*/ |
*/ |
60 |
#define ASSERTRANGE(list,pos,n) \ |
#define ASSERTRANGE(list,pos,n) \ |
61 |
asc_assert(((pos >= 1) && (pos <= GL_LENGTH(list))) || \ |
asc_assert((pos >= 1) && (pos <= GL_LENGTH(list))); |
|
(PRINTF("%s called with illegal length %lu\n",n,pos) == -2)); |
|
62 |
|
|
63 |
#ifndef MOD_REALLOC |
#ifndef MOD_REALLOC |
64 |
#define REALLOCDEBUG FALSE |
#define REALLOCDEBUG FALSE |
130 |
int i; |
int i; |
131 |
if (AllowedContents[0] && |
if (AllowedContents[0] && |
132 |
AllowedContents[0] != MAXRECYCLESMALLITEMS) { |
AllowedContents[0] != MAXRECYCLESMALLITEMS) { |
133 |
PRINTF("gl_init recalled after data corrupted!\n"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"gl_init recalled after data corrupted!\n"); |
134 |
return; |
return; |
135 |
/* somebody called us twice, with intervening nonsense. punt */ |
/* somebody called us twice, with intervening nonsense. punt */ |
136 |
} |
} |
202 |
Asc_Panic(2, NULL, "ERROR: gl_init_pool unable to allocate pool.\n"); |
Asc_Panic(2, NULL, "ERROR: gl_init_pool unable to allocate pool.\n"); |
203 |
} |
} |
204 |
#else |
#else |
205 |
PRINTF("list.[ch] built without pooling of overheads\n"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"list.[ch] built without pooling of overheads\n"); |
206 |
#endif |
#endif |
207 |
} |
} |
208 |
|
|
214 |
pool_destroy_store(g_list_head_pool); |
pool_destroy_store(g_list_head_pool); |
215 |
g_list_head_pool = NULL; |
g_list_head_pool = NULL; |
216 |
#else |
#else |
217 |
PRINTF("list.[ch] built without pooling of overheads\n"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"list.[ch] built without pooling of overheads\n"); |
218 |
#endif |
#endif |
219 |
} |
} |
220 |
|
|
224 |
#if LISTUSESPOOL |
#if LISTUSESPOOL |
225 |
return (g_list_head_pool == NULL) ? FALSE : TRUE; |
return (g_list_head_pool == NULL) ? FALSE : TRUE; |
226 |
#else |
#else |
227 |
PRINTF("list.[ch] built without pooling of overheads\n"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"list.[ch] built without pooling of overheads\n"); |
228 |
return TRUE; |
return TRUE; |
229 |
#endif |
#endif |
230 |
} |
} |
291 |
return new; |
return new; |
292 |
} |
} |
293 |
else { |
else { |
294 |
FPRINTF(ASCERR,"UNABLE TO ALLOCATE MEMORY FOR LIST\n"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"UNABLE TO ALLOCATE MEMORY FOR LIST\n"); |
295 |
return NULL; |
return NULL; |
296 |
} |
} |
297 |
} |
} |
426 |
tmp = (VOIDPTR *) DATAREALLOC(list,increment); |
tmp = (VOIDPTR *) DATAREALLOC(list,increment); |
427 |
|
|
428 |
if (tmp==NULL) { |
if (tmp==NULL) { |
429 |
PRINTF("gl_expand_list: memory allocation failed\n"); |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"gl_expand_list: memory allocation failed"); |
430 |
list->capacity -= increment; |
list->capacity -= increment; |
431 |
} else { |
} else { |
432 |
list->data = tmp; |
list->data = tmp; |
441 |
list->capacity += addlen; |
list->capacity += addlen; |
442 |
list->data = (VOIDPTR *)DATAREALLOC(list,addlen); |
list->data = (VOIDPTR *)DATAREALLOC(list,addlen); |
443 |
|
|
444 |
if (list->data==NULL) PRINTF("gl_expand_list_by: memory allocation failed\n"); |
if (list->data==NULL)ERROR_REPORTER_HERE(ASC_PROG_ERR,"gl_expand_list_by: memory allocation failed\n"); |
445 |
asc_assert(list->data!=NULL); |
asc_assert(list->data!=NULL); |
446 |
} |
} |
447 |
|
|
787 |
list->flags |= gsf_SORTED; |
list->flags |= gsf_SORTED; |
788 |
} |
} |
789 |
else { |
else { |
790 |
PRINTF( |
ERROR_REPORTER_HERE(ASC_PROG_ERR,"gl_insert_sorted called on unsorted list -- sorting list now."); |
|
"Warning gl_insert_sorted called on unsorted list.\nSorting list.\n"); |
|
791 |
gl_append_ptr(list,ptr); |
gl_append_ptr(list,ptr); |
792 |
gl_sort(list,func); |
gl_sort(list,func); |
793 |
} |
} |