summaryrefslogtreecommitdiff
path: root/lib/realloc.c
diff options
context:
space:
mode:
authorwlestes <wlestes>2012-03-21 18:36:28 +0000
committerwlestes <wlestes>2012-03-21 18:36:28 +0000
commit8763c3cf88e4b89c8fb9a352df605282468c3f13 (patch)
tree76bc46c7d9321b26842feb36524df7046a7dace9 /lib/realloc.c
parent7ed646072e5aabd26b724eca44741f54a3889c1a (diff)
downloadflex-8763c3cf88e4b89c8fb9a352df605282468c3f13.tar.gz
provide malloc() and realloc() for systems that do not have satisfactory versions; resolves #1899047
Diffstat (limited to 'lib/realloc.c')
-rw-r--r--lib/realloc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/realloc.c b/lib/realloc.c
new file mode 100644
index 0000000..d7bb629
--- /dev/null
+++ b/lib/realloc.c
@@ -0,0 +1,27 @@
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <errno.h>
+
+void * rpl_realloc (void *p, size_t n)
+{
+ void *result;
+
+ if (n == 0)
+ {
+ n = 1;
+ }
+
+ if (p == NULL)
+ {
+ result = malloc (n);
+ }
+ else
+ result = realloc (p, n);
+
+ if (result == NULL)
+ errno = ENOMEM;
+
+ return result;
+}