effectively use emult_realloc, okay guenther@
authorespie <espie@openbsd.org>
Tue, 22 Apr 2014 08:26:31 +0000 (08:26 +0000)
committerespie <espie@openbsd.org>
Tue, 22 Apr 2014 08:26:31 +0000 (08:26 +0000)
usr.bin/make/garray.h
usr.bin/make/str.c
usr.bin/make/varmodifiers.c

index 01ba165..c8d6708 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef GARRAY_H
 #define GARRAY_H
 
-/* $OpenBSD: garray.h,v 1.6 2010/07/19 19:46:44 espie Exp $ */
+/* $OpenBSD: garray.h,v 1.7 2014/04/22 08:26:31 espie Exp $ */
 /* Growable array implementation */
 
 /*
@@ -52,8 +52,8 @@ do {                                                          \
 do {                                                   \
        if ((l)->n >= (l)->size) {                      \
                (l)->size *= 2;                         \
-               (l)->a = erealloc((l)->a,               \
-                   sizeof(struct GNode *) * (l)->size);\
+               (l)->a = emult_realloc((l)->a,          \
+                   (l)->size, sizeof(struct GNode *)); \
                MAY_INCREASE_STATS;                     \
        }                                               \
        (l)->a[(l)->n++] = (gn);                        \
index 8aee1e3..755d65f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: str.c,v 1.28 2013/11/22 15:47:35 espie Exp $  */
+/*     $OpenBSD: str.c,v 1.29 2014/04/22 08:26:31 espie Exp $  */
 /*     $NetBSD: str.c,v 1.13 1996/11/06 17:59:23 christos Exp $        */
 
 /*-
@@ -150,8 +150,8 @@ brk_string(const char *str, int *store_argc, char **buffer)
                        *t++ = '\0';
                        if (argc == argmax) {
                                argmax *= 2;    /* ramp up fast */
-                               argv = erealloc(argv,
-                                   (argmax + 1) * sizeof(char *));
+                               argv = emult_realloc(argv,
+                                   (argmax + 1), sizeof(char *));
                        }
                        argv[argc++] = start;
                        start = NULL;
index abb7309..149d5c3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: varmodifiers.c,v 1.35 2013/11/22 15:47:35 espie Exp $ */
+/*     $OpenBSD: varmodifiers.c,v 1.36 2014/04/22 08:26:31 espie Exp $ */
 /*     $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $        */
 
 /*
@@ -460,14 +460,14 @@ do_sort(const char *s, const struct Name *dummy UNUSED, void *arg UNUSED)
        const char *start, *end;
 
        n = 1024;       /* start at 1024 words */
-       t = (struct Name *)emalloc(sizeof(struct Name) * n);
+       t = ecalloc(n, sizeof(struct Name));
        start = s;
        end = start;
 
        for (i = 0;; i++) {
                if (i == n) {
                        n *= 2;
-                       t = (struct Name *)erealloc(t, sizeof(struct Name) * n);
+                       t = emult_realloc(t, n, sizeof(struct Name));
                }
                start = iterate_words(&end);
                if (start == NULL)