diff options
author | Andrew Cagney <cagney@redhat.com> | 2000-03-04 00:40:40 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2000-03-04 00:40:40 +0000 |
commit | e400552667bfce4e8569944fa28fa87e65bbdfcc (patch) | |
tree | 4b95a234f538f509c834e1674cfa18f729fbc246 /gdb | |
parent | 6dcbc97b8aa6c242af3db99f9b568868f8c502c7 (diff) | |
download | gdb-e400552667bfce4e8569944fa28fa87e65bbdfcc.zip gdb-e400552667bfce4e8569944fa28fa87e65bbdfcc.tar.gz gdb-e400552667bfce4e8569944fa28fa87e65bbdfcc.tar.bz2 |
Convert make_cleanup functions to ISO-C.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/defs.h | 24 | ||||
-rw-r--r-- | gdb/utils.c | 31 |
3 files changed, 40 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 090179c..5ddd655 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Sat Mar 4 10:57:25 2000 Andrew Cagney <cagney@b1.cygnus.com> + + * defs.h (make_cleanup_func): Document as deprecated. + (make_cleanup_ftype): New typedef. Make signature consistent with + other function typedefs. Document as not be used out side of + make_cleanup code. Use in make_cleanup declarations. + + * utils.c (make_cleanup, make_final_cleanup, make_run_cleanup, + make_exec_cleanup, make_exec_error_cleanup, make_my_cleanup, + null_cleanup): Change K&R definition to ISO-C using void* and + make_cleanup_fytpe. + (discard_my_cleanups): Don't cast argument to free. + 2000-03-03 Elena Zannoni <ezannoni@kwikemart.cygnus.com> * defs.h (struct continuation_arg): Change type of field 'data' @@ -293,24 +293,36 @@ extern void discard_final_cleanups (struct cleanup *); extern void discard_exec_error_cleanups (struct cleanup *); extern void discard_my_cleanups (struct cleanup **, struct cleanup *); +/* DEPRECATED: cagney/2000-03-04: Do not use this typedef to cast + function pointers so that they match the argument to the various + cleanup functions. Post GDB 5.0, this typedef will be + deleted. [Editors note: cagney was the person that added most of + those type casts] */ typedef void (*make_cleanup_func) (void *); -extern struct cleanup *make_cleanup (make_cleanup_func, void *); +/* NOTE: cagney/2000-03-04: This typedef is strictly for the + make_cleanup function declarations below. Do not use this typedef + as a cast when passing functions into the make_cleanup() code. + Instead either use a bounce function or add a wrapper function. + Calling a f(char*) function with f(void*) is non-portable. */ +typedef void (make_cleanup_ftype) (void *); + +extern struct cleanup *make_cleanup (make_cleanup_ftype *, void *); extern struct cleanup *make_cleanup_freeargv (char **); struct ui_file; extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *); -extern struct cleanup *make_final_cleanup (make_cleanup_func, void *); +extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *); extern struct cleanup *make_my_cleanup (struct cleanup **, - make_cleanup_func, void *); + make_cleanup_ftype *, void *); -extern struct cleanup *make_run_cleanup (make_cleanup_func, void *); +extern struct cleanup *make_run_cleanup (make_cleanup_ftype *, void *); -extern struct cleanup *make_exec_cleanup (make_cleanup_func, void *); -extern struct cleanup *make_exec_error_cleanup (make_cleanup_func, void *); +extern struct cleanup *make_exec_cleanup (make_cleanup_ftype *, void *); +extern struct cleanup *make_exec_error_cleanup (make_cleanup_ftype *, void *); extern struct cleanup *save_cleanups (void); extern struct cleanup *save_final_cleanups (void); diff --git a/gdb/utils.c b/gdb/utils.c index 501c861..a4686bb 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -160,41 +160,31 @@ int pagination_enabled = 1; Args are FUNCTION to clean up with, and ARG to pass to it. */ struct cleanup * -make_cleanup (function, arg) - void (*function) PARAMS ((PTR)); - PTR arg; +make_cleanup (make_cleanup_ftype *function, void *arg) { return make_my_cleanup (&cleanup_chain, function, arg); } struct cleanup * -make_final_cleanup (function, arg) - void (*function) PARAMS ((PTR)); - PTR arg; +make_final_cleanup (make_cleanup_ftype *function, void *arg) { return make_my_cleanup (&final_cleanup_chain, function, arg); } struct cleanup * -make_run_cleanup (function, arg) - void (*function) PARAMS ((PTR)); - PTR arg; +make_run_cleanup (make_cleanup_ftype *function, void *arg) { return make_my_cleanup (&run_cleanup_chain, function, arg); } struct cleanup * -make_exec_cleanup (function, arg) - void (*function) PARAMS ((PTR)); - PTR arg; +make_exec_cleanup (make_cleanup_ftype *function, void *arg) { return make_my_cleanup (&exec_cleanup_chain, function, arg); } struct cleanup * -make_exec_error_cleanup (function, arg) - void (*function) PARAMS ((PTR)); - PTR arg; +make_exec_error_cleanup (make_cleanup_ftype *function, void *arg) { return make_my_cleanup (&exec_error_cleanup_chain, function, arg); } @@ -226,10 +216,8 @@ make_cleanup_ui_file_delete (struct ui_file *arg) } struct cleanup * -make_my_cleanup (pmy_chain, function, arg) - struct cleanup **pmy_chain; - void (*function) PARAMS ((PTR)); - PTR arg; +make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function, + void *arg) { register struct cleanup *new = (struct cleanup *) xmalloc (sizeof (struct cleanup)); @@ -328,7 +316,7 @@ discard_my_cleanups (pmy_chain, old_chain) while ((ptr = *pmy_chain) != old_chain) { *pmy_chain = ptr->next; - free ((PTR) ptr); + free (ptr); } } @@ -402,8 +390,7 @@ free_current_contents (location) /* ARGSUSED */ void -null_cleanup (arg) - PTR arg; +null_cleanup (void *arg) { } |