zalloc.c (256281) | zalloc.c (269101) |
---|---|
1/* 2 * This module derived from code donated to the FreeBSD Project by 3 * Matthew Dillon <dillon@backplane.com> 4 * 5 * Copyright (c) 1998 The FreeBSD Project 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/* 2 * This module derived from code donated to the FreeBSD Project by 3 * Matthew Dillon <dillon@backplane.com> 4 * 5 * Copyright (c) 1998 The FreeBSD Project 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: stable/10/lib/libstand/zalloc.c 223905 2011-07-10 07:25:34Z avatar $"); | 31__FBSDID("$FreeBSD: stable/10/lib/libstand/zalloc.c 269101 2014-07-25 23:12:22Z ian $"); |
32 33/* 34 * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation 35 * subsystem 36 * 37 * This subsystem implements memory pools and memory allocation 38 * routines. 39 * --- 26 unchanged lines hidden (view full) --- 66 * only for z[n]alloc(). 67 * 68 * Allocation and frees of 0 bytes are valid operations. 69 */ 70 71#include "zalloc_defs.h" 72 73/* | 32 33/* 34 * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation 35 * subsystem 36 * 37 * This subsystem implements memory pools and memory allocation 38 * routines. 39 * --- 26 unchanged lines hidden (view full) --- 66 * only for z[n]alloc(). 67 * 68 * Allocation and frees of 0 bytes are valid operations. 69 */ 70 71#include "zalloc_defs.h" 72 73/* |
74 * Objects in the pool must be aligned to at least the size of struct MemNode. 75 * They must also be aligned to MALLOCALIGN, which should normally be larger 76 * than the struct, so assert that to be so at compile time. 77 */ 78typedef char assert_align[(sizeof(struct MemNode) <= MALLOCALIGN) ? 1 : -1]; 79 80#define MEMNODE_SIZE_MASK MALLOCALIGN_MASK 81 82/* |
|
74 * znalloc() - allocate memory (without zeroing) from pool. Call reclaim 75 * and retry if appropriate, return NULL if unable to allocate 76 * memory. 77 */ 78 79void * 80znalloc(MemPool *mp, uintptr_t bytes) 81{ --- 226 unchanged lines hidden --- | 83 * znalloc() - allocate memory (without zeroing) from pool. Call reclaim 84 * and retry if appropriate, return NULL if unable to allocate 85 * memory. 86 */ 87 88void * 89znalloc(MemPool *mp, uintptr_t bytes) 90{ --- 226 unchanged lines hidden --- |