X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Ffree-hook.c;h=4d18ca2c078c11d199e5566eb8ea0ff60593530e;hb=2de276bef41f9a7144d104579560f6717cbde299;hp=cac4a86ed9f18b1147227a15bbee26fed65c02ee;hpb=33c8db8e2477d62fd8734f65475f2ed516167532;p=chise%2Fxemacs-chise.git.1 diff --git a/src/free-hook.c b/src/free-hook.c index cac4a86..4d18ca2 100644 --- a/src/free-hook.c +++ b/src/free-hook.c @@ -85,14 +85,14 @@ void *malloc (size_t); /* System function prototypes don't belong in C source files */ /* extern void free (void *); */ -struct hash_table *pointer_table; +static struct hash_table *pointer_table; extern void (*__free_hook) (void *); extern void *(*__malloc_hook) (size_t); static void *check_malloc (size_t); -typedef void (*fun_ptr) (); +typedef void (*fun_ptr) (void); /* free_queue is not too useful without backtrace logging */ #define FREE_QUEUE_LIMIT 1 @@ -110,11 +110,11 @@ typedef struct { unsigned long length; } free_queue_entry; -free_queue_entry free_queue[FREE_QUEUE_LIMIT]; +static free_queue_entry free_queue[FREE_QUEUE_LIMIT]; -int current_free; +static int current_free; -int strict_free_check; +static int strict_free_check; static void check_free (void *ptr) @@ -131,7 +131,7 @@ check_free (void *ptr) #endif EMACS_INT present = (EMACS_INT) gethash (ptr, pointer_table, - (CONST void **) &size); + (const void **) &size); if (!present) { @@ -141,7 +141,7 @@ check_free (void *ptr) /* I originally wrote: "There's really no need to drop core." I have seen the error of my ways. -slb */ if (strict_free_check) - abort (); + ABORT (); #endif printf("Freeing unmalloc'ed memory at %p\n", ptr); __free_hook = check_free; @@ -155,7 +155,7 @@ check_free (void *ptr) #if !defined(__linux__) /* See above comment. */ if (strict_free_check) - abort (); + ABORT (); #endif printf("Freeing %p twice\n", ptr); __free_hook = check_free; @@ -257,14 +257,14 @@ check_realloc (void * ptr, size_t size) void *result = malloc (size); if (!ptr) return result; - present = (EMACS_INT) gethash (ptr, pointer_table, (CONST void **) &old_size); + present = (EMACS_INT) gethash (ptr, pointer_table, (const void **) &old_size); if (!present) { /* This can only happen by reallocing a pointer that didn't come from malloc. */ #if !defined(__linux__) /* see comment in check_free(). */ - abort (); + ABORT (); #endif printf("Realloc'ing unmalloc'ed pointer at %p\n", ptr); } @@ -445,7 +445,7 @@ block_input_history blhist[BLHISTLIMIT]; note_block_input (char *file, int line) { note_block (file, line, block_type); - if (interrupt_input_blocked > 2) abort(); + if (interrupt_input_blocked > 2) ABORT(); } note_unblock_input (char* file, int line) @@ -485,13 +485,15 @@ log_gcpro (char *file, int line, struct gcpro *value, blocktype type) if (type == ungcpro_type) { if (value == gcprolist) goto OK; - if (! gcprolist) abort (); + if (! gcprolist) ABORT (); if (value == gcprolist->next) goto OK; - if (! gcprolist->next) abort (); + if (! gcprolist->next) ABORT (); if (value == gcprolist->next->next) goto OK; - if (! gcprolist->next->next) abort (); + if (! gcprolist->next->next) ABORT (); if (value == gcprolist->next->next->next) goto OK; - abort (); + if (! gcprolist->next->next->next) ABORT (); + if (value == gcprolist->next->next->next->next) goto OK; + ABORT (); OK:; } gcprohist[gcprohistptr].file = file; @@ -587,6 +589,7 @@ show_gcprohist (void) gcprohist[j].type == gcpro2_type ? "GCPRO2" : gcprohist[j].type == gcpro3_type ? "GCPRO3" : gcprohist[j].type == gcpro4_type ? "GCPRO4" : + gcprohist[j].type == gcpro5_type ? "GCPRO5" : gcprohist[j].type == ungcpro_type ? "UNGCPRO" : "???"), gcprohist[j].value); }