modernc.org/cc@v1.0.1/v2/headers/linux_386/usr/include/malloc.h (about) 1 /* Prototypes and definition for malloc implementation. 2 Copyright (C) 1996-2018 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <http://www.gnu.org/licenses/>. */ 18 19 #ifndef _MALLOC_H 20 #define _MALLOC_H 1 21 22 #include <features.h> 23 #include <stddef.h> 24 #include <stdio.h> 25 26 #ifdef _LIBC 27 # define __MALLOC_HOOK_VOLATILE 28 # define __MALLOC_DEPRECATED 29 #else 30 # define __MALLOC_HOOK_VOLATILE volatile 31 # define __MALLOC_DEPRECATED __attribute_deprecated__ 32 #endif 33 34 __BEGIN_DECLS 35 /* Allocate SIZE bytes of memory. */ 36 extern void *malloc(size_t __size) 37 __THROW __attribute_malloc__ __wur; 38 39 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ 40 extern void *calloc(size_t __nmemb, size_t __size) 41 __THROW __attribute_malloc__ __wur; 42 43 /* Re-allocate the previously allocated block in __ptr, making the new 44 block SIZE bytes long. */ 45 /* __attribute_malloc__ is not used, because if realloc returns 46 the same pointer that was passed to it, aliasing needs to be allowed 47 between objects pointed by the old and new pointers. */ 48 extern void *realloc(void *__ptr, size_t __size) 49 __THROW __attribute_warn_unused_result__; 50 51 /* Re-allocate the previously allocated block in PTR, making the new 52 block large enough for NMEMB elements of SIZE bytes each. */ 53 /* __attribute_malloc__ is not used, because if reallocarray returns 54 the same pointer that was passed to it, aliasing needs to be allowed 55 between objects pointed by the old and new pointers. */ 56 extern void *reallocarray(void *__ptr, size_t __nmemb, size_t __size) 57 __THROW __attribute_warn_unused_result__; 58 59 /* Free a block allocated by `malloc', `realloc' or `calloc'. */ 60 extern void free(void *__ptr) __THROW; 61 62 /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ 63 extern void *memalign(size_t __alignment, size_t __size) 64 __THROW __attribute_malloc__ __wur; 65 66 /* Allocate SIZE bytes on a page boundary. */ 67 extern void *valloc(size_t __size) 68 __THROW __attribute_malloc__ __wur; 69 70 /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up 71 __size to nearest pagesize. */ 72 extern void *pvalloc(size_t __size) 73 __THROW __attribute_malloc__ __wur; 74 75 /* Underlying allocation function; successive calls should return 76 contiguous pieces of memory. */ 77 extern void *(*__morecore) (ptrdiff_t __size); 78 79 /* Default value of `__morecore'. */ 80 extern void *__default_morecore(ptrdiff_t __size) 81 __THROW __attribute_malloc__; 82 83 /* SVID2/XPG mallinfo structure */ 84 85 struct mallinfo { 86 int arena; /* non-mmapped space allocated from system */ 87 int ordblks; /* number of free chunks */ 88 int smblks; /* number of fastbin blocks */ 89 int hblks; /* number of mmapped regions */ 90 int hblkhd; /* space in mmapped regions */ 91 int usmblks; /* always 0, preserved for backwards compatibility */ 92 int fsmblks; /* space available in freed fastbin blocks */ 93 int uordblks; /* total allocated space */ 94 int fordblks; /* total free space */ 95 int keepcost; /* top-most, releasable (via malloc_trim) space */ 96 }; 97 98 /* Returns a copy of the updated current mallinfo. */ 99 extern struct mallinfo mallinfo(void) __THROW; 100 101 /* SVID2/XPG mallopt options */ 102 #ifndef M_MXFAST 103 # define M_MXFAST 1 /* maximum request size for "fastbins" */ 104 #endif 105 #ifndef M_NLBLKS 106 # define M_NLBLKS 2 /* UNUSED in this malloc */ 107 #endif 108 #ifndef M_GRAIN 109 # define M_GRAIN 3 /* UNUSED in this malloc */ 110 #endif 111 #ifndef M_KEEP 112 # define M_KEEP 4 /* UNUSED in this malloc */ 113 #endif 114 115 /* mallopt options that actually do something */ 116 #define M_TRIM_THRESHOLD -1 117 #define M_TOP_PAD -2 118 #define M_MMAP_THRESHOLD -3 119 #define M_MMAP_MAX -4 120 #define M_CHECK_ACTION -5 121 #define M_PERTURB -6 122 #define M_ARENA_TEST -7 123 #define M_ARENA_MAX -8 124 125 /* General SVID/XPG interface to tunable parameters. */ 126 extern int mallopt(int __param, int __val) __THROW; 127 128 /* Release all but __pad bytes of freed top-most memory back to the 129 system. Return 1 if successful, else 0. */ 130 extern int malloc_trim(size_t __pad) __THROW; 131 132 /* Report the number of usable allocated bytes associated with allocated 133 chunk __ptr. */ 134 extern size_t malloc_usable_size(void *__ptr) __THROW; 135 136 /* Prints brief summary statistics on stderr. */ 137 extern void malloc_stats(void) __THROW; 138 139 /* Output information about state of allocator to stream FP. */ 140 extern int malloc_info(int __options, FILE * __fp) __THROW; 141 142 /* Hooks for debugging and user-defined versions. */ 143 extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr, const void *)__MALLOC_DEPRECATED; 144 extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook) (size_t __size, const void *)__MALLOC_DEPRECATED; 145 extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook) (void *__ptr, size_t __size, const void *)__MALLOC_DEPRECATED; 146 extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook) (size_t __alignment, size_t __size, const void *)__MALLOC_DEPRECATED; 147 extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void); 148 149 /* Activate a standard set of debugging hooks. */ 150 extern void __malloc_check_init(void) 151 __THROW __MALLOC_DEPRECATED; 152 153 __END_DECLS 154 #endif /* malloc.h */