Convert make_cleanup functions to ISO-C.
authorAndrew Cagney <cagney@redhat.com>
Sat, 4 Mar 2000 00:40:40 +0000 (00:40 +0000)
committerAndrew Cagney <cagney@redhat.com>
Sat, 4 Mar 2000 00:40:40 +0000 (00:40 +0000)
gdb/ChangeLog
gdb/defs.h
gdb/utils.c

index 090179c..5ddd655 100644 (file)
@@ -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'
index 3a3ebf8..99e8d14 100644 (file)
@@ -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);
index 501c861..a4686bb 100644 (file)
@@ -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)
 {
 }