]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix wishlist item 82098, thanks to Ralf Wildenhues:
authorNicholas Nethercote <n.nethercote@gmail.com>
Wed, 2 Jun 2004 20:43:24 +0000 (20:43 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Wed, 2 Jun 2004 20:43:24 +0000 (20:43 +0000)
  ANSIfication of the hp2ps code. The most important changes are the correct
  use of the stdarg mechanism (former hacks could bite on other systems, so
  please tell upstream), inclusion of stdlib.h instead of declaring free
  yourself, adding a few missed PROTO()s and using size_t for xmalloc and
  xrealloc.:

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2399

massif/hp2ps/AreaBelow.c
massif/hp2ps/Curves.c
massif/hp2ps/Deviation.c
massif/hp2ps/Error.c
massif/hp2ps/Error.h
massif/hp2ps/Scale.c
massif/hp2ps/TopTwenty.c
massif/hp2ps/TraceElement.c
massif/hp2ps/Utilities.c
massif/hp2ps/Utilities.h

index 46e4ba04345b155fc0d4bf04fa62c43a5a5e9461..e14ed5ebedac36ccc4c0158a30cc8be2cf4cfda7 100644 (file)
@@ -3,6 +3,7 @@
    This program is governed by the license contained in the file LICENSE.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include "Main.h"
 #include "Defines.h"
 #include "Error.h"
@@ -12,8 +13,6 @@
 /* own stuff */
 #include "AreaBelow.h"
 
-extern void free();
-
 /*
  *      Return the area enclosed by all of the curves. The algorithm
  *     used is the same as the trapizoidal rule for integration. 
index b7ad82499272b7e92859518914e07a8de7bdd33a..5176ecf8fe29ea87676146a7d16e3cf59b0c0157 100644 (file)
@@ -20,7 +20,8 @@ static floatish *g_y;
 static floatish *g_py;         /* previous y values */
 
 static void Curve PROTO((struct entry *));     /* forward */
-static void ShadeCurve();                      /* forward */
+static void ShadeCurve
+    PROTO((floatish *x, floatish *y, floatish *py, floatish shade));
 
 void
 Curves()
index bfc0f44b46b49721245bb2cc404925bf9b468f5f..22a0e9ed4fddb43332a875260eafc3ce2bbdc7cd 100644 (file)
@@ -3,6 +3,7 @@
    This program is governed by the license contained in the file LICENSE.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <math.h>
 #include "Main.h"
@@ -11,8 +12,6 @@
 #include "HpFile.h"
 #include "Utilities.h"
 
-extern void free();
-
 /* own stuff */
 #include "Deviation.h"
 
index 9078acf212b755b818580db81f4bac629c4329d2..2ecba3da691907939e99ecfc8d2cc114de6f10e0 100644 (file)
@@ -2,43 +2,47 @@
    Copyright (C) 2002 The University Court of the University of Glasgow.
    This program is governed by the license contained in the file LICENSE.  */
 
+#include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "Main.h"
 #include "Defines.h"
 
 /* own stuff */
 #include "Error.h"
 
-void exit PROTO((int));
-
 /*VARARGS0*/
 void
-Error(a1,a2,a3,a4)
-  char* a1; char* a2; char* a3; char* a4;
+Error(const char *fmt, ...)
 {
+    va_list ap;
     fflush(stdout);
     fprintf(stderr, "%s: ", programname);
-    fprintf(stderr, a1, a2, a3, a4);
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
     fprintf(stderr, "\n");
     exit(1);
 }
 
 /*VARARGS0*/
 void
-Disaster(a1,a2,a3,a4)
-  char* a1; char* a2; char* a3; char* a4;
+Disaster(const char *fmt, ...)
 {
+    va_list ap;
     fflush(stdout);
     fprintf(stderr, "%s: ", programname);
-    fprintf(stderr, " Disaster! ("); 
-    fprintf(stderr, a1, a2, a3, a4);
+    fprintf(stderr, " Disaster! (");
+    va_start(ap, fmt);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
     fprintf(stderr, ")\n");
     exit(1);
 }
 
 void
 Usage(str)
-  char *str;
+  const char *str;
 {
    if (str) printf("error: %s\n", str);
    printf("usage: %s -b -d -ef -g -i -p -mn -p -s -tf -y [file[.hp]]\n", programname);
index b478672e93d7408912805747abcdca1e2390e99b..d38518d699533c2208d229d7e32110d453368a1e 100644 (file)
@@ -5,8 +5,8 @@
 #ifndef ERROR_H
 #define ERROR_H
 
-extern void Error    (); /*PROTO((char *, ...)); */
-extern void Disaster (); /* PROTO((char *, ...)); */
-extern void Usage    (); /* PROTO((char *)); */
+extern void Error    PROTO((const char *, ...));
+extern void Disaster PROTO((const char *, ...));
+extern void Usage    PROTO((const char *));
 
 #endif /* ERROR_H */
index 7f023fd0755f47126e43cbf97954cc9f91bfa59b..b6b5e3a9ec42107bafaae3626becaadb0d33b8ec 100644 (file)
@@ -3,6 +3,7 @@
    This program is governed by the license contained in the file LICENSE.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include "Main.h"
 #include "Defines.h"
 #include "Dimensions.h"
@@ -20,8 +21,6 @@
  *     fit on the page.
  */
 
-extern void free();
-
 floatish
 MaxCombinedHeight()
 {
index b627bfff6778633f96bba20ad17a004d6dd70338..3c6ccbde0f4ab665271b76b5ea47c04221741d81 100644 (file)
@@ -3,6 +3,7 @@
    This program is governed by the license contained in the file LICENSE.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include "Main.h"
 #include "Defines.h"
 #include "Error.h"
@@ -21,8 +22,6 @@
  *     band which appears as band 20.
  */
 
-extern void free();
-
 void
 TopTwenty()
 {
index f603f7c3dd84ff1740db622988293b8578f9e75e..158eb938d0cf0be6287649b838c2f11b9cb986de 100644 (file)
@@ -3,6 +3,7 @@
    This program is governed by the license contained in the file LICENSE.  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include "Main.h"
 #include "Defines.h"
 #include "HpFile.h"
@@ -20,8 +21,6 @@
  *     elements'' and they are thrown away.    
  */
 
-extern void free();
-
 extern floatish thresholdpercent;
 
 void TraceElement()
index 0f0ba590e0e301941c85083612594b4afbfab61e..754cc8a01a965bac3e6180b126451af30d6ebf9f 100644 (file)
@@ -83,7 +83,7 @@ CommaPrint(fp,n)
 
 void *
 xmalloc(n)
-  int n;
+  size_t n;
 {
     void *r;
 
@@ -98,7 +98,7 @@ xmalloc(n)
 void *
 xrealloc(p, n)
   void *p;
-  int n;
+  size_t n;
 {
     void *r;
     extern void *realloc();
index c99434c6d0c958dc7d6faa8b329820db5570457c..674843a65d1de20c3afe1531d37eab581b5014c9 100644 (file)
@@ -11,7 +11,7 @@ FILE* OpenFile    PROTO((char *, char *));
 void  CommaPrint  PROTO((FILE *, intish));
 char *copystring  PROTO((char *));
 char *copystring2 PROTO((char *, char *));
-void *xmalloc   PROTO((int));
-void *xrealloc  PROTO((void *, int));
+void *xmalloc   PROTO((size_t));
+void *xrealloc  PROTO((void *, size_t));
 
 #endif /* UTILITIES_H */