X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=src%2Ffree-hook.c;h=d243aeb0d763db620ecbc67674571439c4ae42eb;hp=07a5edd7b3c7054749c34eacd833633393197ee3;hb=716cfba952c1dc0d2cf5c968971f3780ba728a89;hpb=77dcef404dc78635f6ffa8f71a803d2bc7cc8921 diff --git a/src/free-hook.c b/src/free-hook.c index 07a5edd..d243aeb 100644 --- a/src/free-hook.c +++ b/src/free-hook.c @@ -66,7 +66,7 @@ Boston, MA 02111-1307, USA. */ #include #include "lisp.h" #else -void *malloc (unsigned long); +void *malloc (size_t); #endif #if !defined(HAVE_LIBMCHECK) @@ -85,14 +85,14 @@ void *malloc (unsigned long); /* 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) (unsigned long); +extern void *(*__malloc_hook) (size_t); -static void *check_malloc (unsigned long); +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) @@ -212,9 +212,9 @@ check_free (void *ptr) } static void * -check_malloc (unsigned long size) +check_malloc (size_t size) { - unsigned long rounded_up_size; + size_t rounded_up_size; void *result; __free_hook = 0; @@ -240,7 +240,7 @@ check_malloc (unsigned long size) return result; } -extern void *(*__realloc_hook) (void *, unsigned long); +extern void *(*__realloc_hook) (void *, size_t); #ifdef MIN #undef MIN @@ -250,10 +250,10 @@ extern void *(*__realloc_hook) (void *, unsigned long); /* Don't optimize realloc */ static void * -check_realloc (void * ptr, unsigned long size) +check_realloc (void * ptr, size_t size) { EMACS_INT present; - unsigned long old_size; + size_t old_size; void *result = malloc (size); if (!ptr) return result; @@ -295,7 +295,7 @@ disable_strict_free_check (void) completely gone in XEmacs */ static void * -block_input_malloc (unsigned long size); +block_input_malloc (size_t size); static void block_input_free (void* ptr) @@ -308,7 +308,7 @@ block_input_free (void* ptr) } static void * -block_input_malloc (unsigned long size) +block_input_malloc (size_t size) { void* result; __free_hook = 0; @@ -321,7 +321,7 @@ block_input_malloc (unsigned long size) static void * -block_input_realloc (void* ptr, unsigned long size) +block_input_realloc (void* ptr, size_t size) { void* result; __free_hook = 0; @@ -406,9 +406,9 @@ syms_of_free_hook (void) } #else -void (*__free_hook)() = check_free; -void *(*__malloc_hook)() = check_malloc; -void *(*__realloc_hook)() = check_realloc; +void (*__free_hook)(void *) = check_free; +void *(*__malloc_hook)(size_t) = check_malloc; +void *(*__realloc_hook)(void *, size_t) = check_realloc; #endif #endif /* !defined(HAVE_LIBMCHECK) */ @@ -418,7 +418,8 @@ void *(*__realloc_hook)() = check_realloc; /* Note: There is no more input blocking in XEmacs */ typedef enum { block_type, unblock_type, totally_type, - gcpro1_type, gcpro2_type, gcpro3_type, gcpro4_type, ungcpro_type + gcpro1_type, gcpro2_type, gcpro3_type, gcpro4_type, gcpro5_type, + ungcpro_type } blocktype; struct block_input_history_struct @@ -431,7 +432,7 @@ struct block_input_history_struct typedef struct block_input_history_struct block_input_history; -#endif +#endif /* DEBUG_INPUT_BLOCKING || DEBUG_GCPRO */ #ifdef DEBUG_INPUT_BLOCKING @@ -469,7 +470,7 @@ note_block (char *file, int line, blocktype type) blhistptr = 0; } -#endif +#endif /* DEBUG_INPUT_BLOCKING */ #ifdef DEBUG_GCPRO @@ -481,8 +482,6 @@ block_input_history gcprohist[GCPROHISTLIMIT]; static void log_gcpro (char *file, int line, struct gcpro *value, blocktype type) { - FRAME start_frame; - if (type == ungcpro_type) { if (value == gcprolist) goto OK; @@ -569,6 +568,9 @@ debug_ungcpro (char *file, int line, struct gcpro *gcpro1) gcprolist = gcpro1->next; } + +/* To be called from the debugger */ +void show_gcprohist (void); void show_gcprohist (void) { @@ -591,4 +593,4 @@ show_gcprohist (void) fflush (stdout); } -#endif +#endif /* DEBUG_GCPRO */