[libdispatch-changes] [176] trunk/src/shims/malloc_zone.h

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 28 03:28:27 PST 2009


Revision: 176
          http://trac.macosforge.org/projects/libdispatch/changeset/176
Author:   robert at fledge.watson.org
Date:     2009-12-28 03:28:23 -0800 (Mon, 28 Dec 2009)
Log Message:
-----------
Rather than returning NULL from malloc_create_zone and malloc_default_zone,
return (void *)-1 on platforms without malloc zone support.  Assertions
under DISPATCH_DEBUG appear to require a non-NULL result, so provide one but
not a pointer that can be used for anything (since that would be a bug).

This is slightly different from the submitted patch, which returned a small
ammount of malloc'd memory, in that I want to cause a segfault if the
returned pointer is ever dereferenced, since that would imply a consumer
that knows more about the internals than we implement in our stubs.

Submitted by:	Martin Nowack <martin.nowack at inf.tu-dresden.de>

Modified Paths:
--------------
    trunk/src/shims/malloc_zone.h

Modified: trunk/src/shims/malloc_zone.h
===================================================================
--- trunk/src/shims/malloc_zone.h	2009-12-24 18:48:47 UTC (rev 175)
+++ trunk/src/shims/malloc_zone.h	2009-12-28 11:28:23 UTC (rev 176)
@@ -36,7 +36,7 @@
 malloc_create_zone(size_t start_size, unsigned flags)
 {
 
-	return (NULL);
+	return ((void *)(-1));
 }
 
 static inline void
@@ -49,14 +49,14 @@
 malloc_default_zone(void)
 {
 
-	return (NULL);
+	return ((void *)(-1));
 }
 
 static inline malloc_zone_t *
 malloc_zone_from_ptr(const void *ptr)
 {
 
-	return (NULL);
+	return ((void *)(-1));
 }
 
 static inline void *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-changes/attachments/20091228/72c7d03d/attachment.html>


More information about the libdispatch-changes mailing list