summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2008-04-09 22:07:50 +0000
committerroot <root>2008-04-09 22:07:50 +0000
commit03f02a76c6e1b5786c8afa4e95d8d72e2a91a915 (patch)
treef9129eb4e9864e491a8706c76859f0f91febaf87 /ev.c
parentabf163da58241583484ef39140ef6246411a3ac8 (diff)
*** empty log message ***
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/ev.c b/ev.c
index 68adb7e..51a070e 100644
--- a/ev.c
+++ b/ev.c
@@ -362,7 +362,22 @@ syserr (const char *msg)
}
}
-static void *(*alloc)(void *ptr, long size);
+static void *
+ev_realloc_emul (void *ptr, long size)
+{
+ /* some systems, notably openbsd and darwin, fail to properly
+ * implement realloc (x, 0) (as required by both ansi c-98 and
+ * the single unix specification, so work around them here.
+ */
+
+ if (size)
+ return realloc (ptr, size);
+
+ free (ptr);
+ return 0;
+}
+
+static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
void
ev_set_allocator (void *(*cb)(void *ptr, long size))
@@ -373,7 +388,7 @@ ev_set_allocator (void *(*cb)(void *ptr, long size))
inline_speed void *
ev_realloc (void *ptr, long size)
{
- ptr = alloc ? alloc (ptr, size) : realloc (ptr, size);
+ ptr = alloc (ptr, size);
if (!ptr && size)
{