1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
--- malloc-2.8.6.c 2016-05-23 13:25:14.000000000 +0100
+++ malloc.c 2019-04-28 14:42:16.225706331 +0100
@@ -1,3 +1,62 @@
+/* malloc( size_t )
+ calloc( size_t, size_t )
+ realloc( void *, size_t )
+ aligned_alloc( size_t, size_t )
+ free( void * )
+
+ This file is part of the Public Domain C Library (PDCLib).
+ Permission is granted to use, modify, and / or redistribute at will.
+
+ It is a slightly modified copy of Doug Lea's malloc(), retrieved from
+ ftp://gee.cs.oswego.edu/pub/misc/malloc.c
+ at version 2.8.6, which is released under CC0 license just as PDCLib.
+*/
+
+/* Declared implicitly by dlmalloc. This declaration avoids the warning. */
+#include <stdint.h>
+void * sbrk( intptr_t );
+
+#ifndef REGTEST
+
+#include "_PDCLIB_config.h"
+
+/* Have all functions herein use the dl* prefix */
+#define USE_DL_PREFIX 1
+
+/* Thread safety */
+#define USE_LOCKS 1
+
+/* Hide all functions herein as internal to the library */
+#define DLMALLOC_EXPORT _PDCLIB_LOCAL
+
+/* Unhide the standard functions. (Their declarations with the
+ DLMALLOC_EXPORT modifier below has been commented out; they
+ are declared _PDCLIB_PUBLIC in <stdlib.h>, marking them
+ exported from the library.)
+*/
+#define dlmalloc malloc
+#define dlcalloc calloc
+#define dlrealloc realloc
+#define dlfree free
+#if __STDC_VERSION__ >= 201112L
+#define dlmemalign aligned_alloc
+#endif
+
+#endif
+
+#ifdef TEST
+
+#include "_PDCLIB_test.h"
+
+int main( void )
+{
+ TESTCASE( NO_TESTDRIVER );
+ return TEST_RESULTS;
+}
+
+#endif
+
+/* ------------------------------------------------------------------- */
/*
This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
@@ -585,8 +644,15 @@
#define MAX_SIZE_T (~(size_t)0)
#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */
-#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
- (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
+/* defined() in the expansion of a macro is non-portable behavior
+ and runs afoul of -Wextra.
+*/
+#if ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \
+ (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0))
+#define USE_LOCKS 1
+#else
+#define USE_LOCKS 0
+#endif
#endif /* USE_LOCKS */
#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */
@@ -851,7 +917,7 @@
maximum supported value of n differs across systems, but is in all
cases less than the maximum representable value of a size_t.
*/
-DLMALLOC_EXPORT void* dlmalloc(size_t);
+/*DLMALLOC_EXPORT void* dlmalloc(size_t);*/
/*
free(void* p)
@@ -860,14 +926,14 @@
It has no effect if p is null. If p was not malloced or already
freed, free(p) will by default cause the current program to abort.
*/
-DLMALLOC_EXPORT void dlfree(void*);
+/*DLMALLOC_EXPORT void dlfree(void*);*/
/*
calloc(size_t n_elements, size_t element_size);
Returns a pointer to n_elements * element_size bytes, with all locations
set to zero.
*/
-DLMALLOC_EXPORT void* dlcalloc(size_t, size_t);
+/*DLMALLOC_EXPORT void* dlcalloc(size_t, size_t);*/
/*
realloc(void* p, size_t n)
@@ -891,7 +957,7 @@
The old unix realloc convention of allowing the last-free'd chunk
to be used as an argument to realloc is not supported.
*/
-DLMALLOC_EXPORT void* dlrealloc(void*, size_t);
+/*DLMALLOC_EXPORT void* dlrealloc(void*, size_t);*/
/*
realloc_in_place(void* p, size_t n)
@@ -996,7 +1062,7 @@
guarantee that this number of bytes can actually be obtained from
the system.
*/
-DLMALLOC_EXPORT size_t dlmalloc_footprint_limit();
+DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(void);
/*
malloc_set_footprint_limit();
|