/[ascend]/trunk/base/generic/general/list.c
ViewVC logotype

Diff of /trunk/base/generic/general/list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 927 by johnpye, Wed Jun 28 16:28:57 2006 UTC revision 928 by johnpye, Wed Nov 22 10:32:18 2006 UTC
# Line 31  Line 31 
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"
# Line 57  static const unsigned long MIN_INCREMENT Line 58  static const unsigned long MIN_INCREMENT
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
# Line 130  void gl_init(void) Line 130  void gl_init(void)
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    }    }
# Line 202  void gl_init_pool(void) { Line 202  void gl_init_pool(void) {
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    
# Line 214  void gl_destroy_pool(void) { Line 214  void gl_destroy_pool(void) {
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    
# Line 224  int gl_pool_initialized(void) Line 224  int gl_pool_initialized(void)
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  }  }
# Line 291  struct gl_list_t *gl_create(unsigned lon Line 291  struct gl_list_t *gl_create(unsigned lon
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  }  }
# Line 426  static void gl_expand_list(struct gl_lis Line 426  static void gl_expand_list(struct gl_lis
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;
# Line 441  static void gl_expand_list_by(struct gl_ Line 441  static void gl_expand_list_by(struct gl_
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    
# Line 787  void gl_insert_sorted(struct gl_list_t * Line 787  void gl_insert_sorted(struct gl_list_t *
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    }    }

Legend:
Removed from v.927  
changed lines
  Added in v.928

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22