INN commit: trunk/lib (vector.c)
INN Commit
rra at isc.org
Sat Sep 6 07:18:09 UTC 2014
Date: Saturday, September 6, 2014 @ 00:18:09
Author: iulius
Revision: 9678
Sync the vector library with latest upstream rra-c-util
Use xreallocarray instead of xrealloc in the vector library.
Modified:
trunk/lib/vector.c
----------+
vector.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
Modified: vector.c
===================================================================
--- vector.c 2014-09-05 19:32:31 UTC (rev 9677)
+++ vector.c 2014-09-06 07:18:09 UTC (rev 9678)
@@ -37,12 +37,13 @@
#include "config.h"
#include "clibrary.h"
+
#include <assert.h>
-#include <ctype.h>
#include "inn/vector.h"
-#include "inn/libinn.h"
+#include "inn/xmalloc.h"
+
/*
* Allocate a new, empty vector.
*/
@@ -70,9 +71,9 @@
/*
- * Resize a vector (using realloc to resize the table). Maintain a minimum
- * allocated size of 1 so that the strings data element is never NULL. This
- * simplifies other code.
+ * Resize a vector (using reallocarray to resize the table). Maintain a
+ * minimum allocated size of 1 so that the strings data element is never NULL.
+ * This simplifies other code.
*/
void
vector_resize(struct vector *vector, size_t size)
@@ -87,7 +88,7 @@
}
if (size == 0)
size = 1;
- vector->strings = xrealloc(vector->strings, size * sizeof(char *));
+ vector->strings = xreallocarray(vector->strings, size, sizeof(char *));
vector->allocated = size;
}
@@ -100,7 +101,7 @@
if (size == 0)
size = 1;
vector->strings
- = xrealloc(vector->strings, size * sizeof(const char *));
+ = xreallocarray(vector->strings, size, sizeof(const char *));
vector->allocated = size;
}
More information about the inn-committers
mailing list