This avoids some potential integer overflows.
#include <stdlib.h>
#include "cgraph.h"
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
#define NEW(t) (t*)malloc(sizeof(t))
typedef struct {
#include <string.h>
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
#include "cgraph.h"
#include "cghdr.h"
#include <getopt.h>
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
static int Verbose;
static char* gname = "";
#include <assert.h>
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
#define RALLOC(size,ptr,type) ((type*)realloc(ptr,(size)*sizeof(type)))
typedef unsigned short ushort;
};
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
/* Round x up to next multiple of y, which is a power of 2 */
#define ROUND2(x,y) (((x) + ((y)-1)) & ~((y)-1))
#define SMALLBUF 128
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
#define EMPTY(s) ((s == 0) || (*s == '\0'))
#define SLEN(s) (sizeof(s)-1)
};
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
/* Round x up to next multiple of y, which is a power of 2 */
#define ROUND2(x,y) (((x) + ((y)-1)) & ~((y)-1))
#include <stdlib.h>
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
typedef struct {
unsigned char on_stack;
#include <string.h>
#include <agxbuf.h>
-#define N_GNEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_GNEW(n,t) (t*)calloc((n),sizeof(t))
/* agxbinit:
* Assume if init is non-null, hint = sizeof(init[])
#endif
#define NEW(t) (t*)zmalloc(sizeof(t))
-#define N_NEW(n,t) (t*)zmalloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)gcalloc((n),sizeof(t))
#define GNEW(t) (t*)gmalloc(sizeof(t))
-#define N_GNEW(n,t) (t*)gmalloc((n)*sizeof(t))
-#define N_GGNEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_GNEW(n,t) (t*)gcalloc((n),sizeof(t))
+#define N_GGNEW(n,t) (t*)calloc((n),sizeof(t))
#define ALLOC(size,ptr,type) (ptr? (type*)grealloc(ptr,(size)*sizeof(type)):(type*)gmalloc((size)*sizeof(type)))
#define RALLOC(size,ptr,type) ((type*)grealloc(ptr,(size)*sizeof(type)))
#define ZALLOC(size,ptr,type,osize) (ptr? (type*)zrealloc(ptr,size,sizeof(type),osize):(type*)zmalloc((size)*sizeof(type)))
#include <string.h>
#include <agxbuf.h>
-#define N_GNEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_GNEW(n,t) (t*)calloc((n),sizeof(t))
/* agxbinit:
* Assume if init is non-null, hint = sizeof(init[])
#define MALLOC malloc
#define REALLOC realloc
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
#define NEW(t) (t*)malloc(sizeof(t))
#define MAX(a,b) ((a)>(b)?(a):b)
#define MIN(a,b) ((a)<(b)?(a):b)
} availfont_t;
#define NEW(t) (t*)malloc(sizeof(t))
-#define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
+#define N_NEW(n,t) (t*)calloc((n),sizeof(t))
static PostscriptAlias postscript_alias[] = {
#include "ps_font_equiv.h"