bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory leaks in windres


From: Alan Modra
Subject: Re: Memory leaks in windres
Date: Mon, 6 May 2002 08:54:40 +0930
User-agent: Mutt/1.3.25i

Some cleanups I noticed when fiddling around.

binutils/ChangeLog
        * dlltool.c (process_def_file): Add missing prototype.
        (new_directive, assemble_file, main): Likewise.
        (process_def_file, new_directive): Make static.
        (inform): Rewrite using VA_FIXEDARG.
        * dllwrap.c (mybasename): Add missing prototype.
        (strhash, main): Likewise.
        (inform): Rewrite using VA_FIXEDARG.
        (warn): Likewise.
        (cleanup_and_exit): Use old style function definition.
        (strhash): Likewise.
        * windres.c (define_resource): Use one memset to clear all of
        struct res_resource.

Index: binutils/dlltool.c
===================================================================
RCS file: /cvs/src/src/binutils/dlltool.c,v
retrieving revision 1.33
diff -u -p -r1.33 dlltool.c
--- binutils/dlltool.c  1 Mar 2002 15:34:32 -0000       1.33
+++ binutils/dlltool.c  5 May 2002 23:05:41 -0000
@@ -658,6 +658,8 @@ static struct string_list *excludes;
 static const char *rvaafter PARAMS ((int));
 static const char *rvabefore PARAMS ((int));
 static const char *asm_prefix PARAMS ((int));
+static void process_def_file PARAMS ((const char *));
+static void new_directive PARAMS ((char *));
 static void append_import PARAMS ((const char *, const char *, int));
 static void run PARAMS ((const char *, char *));
 static void scan_drectve_symbols PARAMS ((bfd *));
@@ -674,6 +676,7 @@ static int sfunc PARAMS ((const void *, 
 static void flush_page PARAMS ((FILE *, long *, int, int));
 static void gen_def_file PARAMS ((void));
 static void generate_idata_ofile PARAMS ((FILE *));
+static void assemble_file PARAMS ((const char *, const char *));
 static void gen_exp_file PARAMS ((void));
 static const char *xlate PARAMS ((const char *));
 #if 0
@@ -697,28 +700,17 @@ static void inform PARAMS ((const char *
 
 
 static void
-#ifdef __STDC__
-inform (const char * message, ...)
-#else
-inform (message, va_alist)
-     const char * message;
-     va_dcl
-#endif
+inform VPARAMS ((const char *message, ...))
 {
-  va_list args;
-  
+  VA_OPEN (args, message);
+  VA_FIXEDARG (args, const char *, message);
+
   if (!verbose)
     return;
 
-#ifdef __STDC__
-  va_start (args, message);
-#else
-  va_start (args);
-#endif
-
   report (message, args);
-  
-  va_end (args);
+
+  VA_CLOSE (args);
 }
 
 static const char *
@@ -820,7 +812,7 @@ asm_prefix (machine)
 
 static char **oav;
 
-void
+static void
 process_def_file (name)
      const char *name;
 {
@@ -943,7 +935,7 @@ def_description (desc)
   d_list = d;
 }
 
-void
+static void
 new_directive (dir)
      char *dir;
 {
@@ -3205,6 +3197,8 @@ static const struct option long_options[
   {"compat-implib", no_argument, NULL, 'C'},
   {NULL,0,NULL,0}
 };
+
+int main PARAMS ((int, char **));
 
 int
 main (ac, av)
Index: binutils/dllwrap.c
===================================================================
RCS file: /cvs/src/src/binutils/dllwrap.c,v
retrieving revision 1.10
diff -u -p -r1.10 dllwrap.c
--- binutils/dllwrap.c  23 Jan 2002 16:12:55 -0000      1.10
+++ binutils/dllwrap.c  5 May 2002 23:05:41 -0000
@@ -115,14 +115,16 @@ static int delete_exp_file = 1;
 static int delete_def_file = 1;
 
 static int run PARAMS ((const char *, char *));
+static char *mybasename PARAMS ((const char *));
+static int strhash PARAMS ((const char *));
 static void usage PARAMS ((FILE *, int));
 static void display PARAMS ((const char *, va_list));
 static void inform PARAMS ((const char *, ...));
-static void warn PARAMS ((const char *format, ...));
+static void warn PARAMS ((const char *, ...));
 static char *look_for_prog PARAMS ((const char *, const char *, int));
 static char *deduce_name PARAMS ((const char *));
 static void delete_temp_files PARAMS ((void));
-static void cleanup_and_exit PARAMS ((int status));
+static void cleanup_and_exit PARAMS ((int));
 
 /**********************************************************************/
 
@@ -147,58 +149,30 @@ display (message, args)
 }
 
 
-#ifdef __STDC__
 static void
-inform (const char * message, ...)
+inform VPARAMS ((const char *message, ...))
 {
-  va_list args;
+  VA_OPEN (args, message);
+  VA_FIXEDARG (args, const char *, message);
 
   if (!verbose)
     return;
 
-  va_start (args, message);
   display (message, args);
-  va_end (args);
-}
 
-static void
-warn (const char *format, ...)
-{
-  va_list args;
-
-  va_start (args, format);
-  display (format, args);
-  va_end (args);
+  VA_CLOSE (args);
 }
-#else
 
 static void
-inform (message, va_alist)
-     const char * message;
-     va_dcl
+warn VPARAMS ((const char *format, ...))
 {
-  va_list args;
+  VA_OPEN (args, format);
+  VA_FIXEDARG (args, const char *, format);
 
-  if (!verbose)
-    return;
-
-  va_start (args);
-  display (message, args);
-  va_end (args);
-}
-
-static void
-warn (format, va_alist)
-     const char *format;
-     va_dcl
-{
-  va_list args;
-
-  va_start (args);
   display (format, args);
-  va_end (args);
+
+  VA_CLOSE (args);
 }
-#endif
 
 /* Look for the program formed by concatenating PROG_NAME and the
    string running from PREFIX to END_PREFIX.  If the concatenated
@@ -375,7 +349,8 @@ delete_temp_files ()
 }
 
 static void 
-cleanup_and_exit (int status)
+cleanup_and_exit (status)
+     int status;
 {
   delete_temp_files ();
   exit (status);
@@ -487,7 +462,8 @@ mybasename (name)
 }
 
 static int 
-strhash (const char *str)
+strhash (str)
+     const char *str;
 {
   const unsigned char *s;
   unsigned long hash;
@@ -634,6 +610,8 @@ static const struct option long_options[
   {"as", required_argument, NULL, OPTION_AS},
   {0, 0, 0, 0}
 };
+
+int main PARAMS ((int, char **));
 
 int
 main (argc, argv)
Index: binutils/windres.c
===================================================================
RCS file: /cvs/src/src/binutils/windres.c,v
retrieving revision 1.12
diff -u -p -r1.12 windres.c
--- binutils/windres.c  9 Apr 2002 16:55:47 -0000       1.12
+++ binutils/windres.c  5 May 2002 23:05:44 -0000
@@ -443,11 +443,9 @@ define_resource (resources, cids, ids, d
 
   re->u.res = ((struct res_resource *)
               res_alloc (sizeof (struct res_resource)));
+  memset (re->u.res, 0, sizeof (struct res_resource));
 
   re->u.res->type = RES_TYPE_UNINITIALIZED;
-  memset (&re->u.res->res_info, 0, sizeof (struct res_res_info));
-  memset (&re->u.res->coff_info, 0, sizeof (struct res_coff_info));
-
   return re->u.res;
 }
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



reply via email to

[Prev in Thread] Current Thread [Next in Thread]