zalloc_mem.h revision 267654
152400Sbillf/*
252400Sbillf * This module derived from code donated to the FreeBSD Project by
352400Sbillf * Matthew Dillon <dillon@backplane.com>
452400Sbillf *
552400Sbillf * Copyright (c) 1998 The FreeBSD Project
652400Sbillf * All rights reserved.
752400Sbillf *
8124053Sdougb * Redistribution and use in source and binary forms, with or without
973651Sdougb * modification, are permitted provided that the following conditions
1052400Sbillf * are met:
1152495Sbillf * 1. Redistributions of source code must retain the above copyright
1252400Sbillf *    notice, this list of conditions and the following disclaimer.
1368507Sdougb * 2. Redistributions in binary form must reproduce the above copyright
1452400Sbillf *    notice, this list of conditions and the following disclaimer in the
1552400Sbillf *    documentation and/or other materials provided with the distribution.
1652533Sbillf *
1752400Sbillf * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18114501Sdougb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1967949Sdougb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2052400Sbillf * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2152400Sbillf * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2252400Sbillf * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2352400Sbillf * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2452400Sbillf * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2552400Sbillf * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2652400Sbillf * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2767949Sdougb * SUCH DAMAGE.
2891193Sdougb *
2991193Sdougb * $FreeBSD: releng/9.3/lib/libstand/zalloc_mem.h 223905 2011-07-10 07:25:34Z avatar $
30114501Sdougb */
3152400Sbillf
3252400Sbillf/*
3352400Sbillf * H/MEM.H
3452400Sbillf *
3552400Sbillf * Basic memory pool / memory node structures.
3667949Sdougb */
3752400Sbillf
3852400Sbillftypedef struct MemNode {
3952400Sbillf    struct MemNode	*mr_Next;
4052400Sbillf    uintptr_t		mr_Bytes;
4152400Sbillf} MemNode;
4252400Sbillf
4352400Sbillftypedef struct MemPool {
4467859Sdougb    void		*mp_Base;
4567949Sdougb    void		*mp_End;
4652400Sbillf    MemNode		*mp_First;
4752400Sbillf    uintptr_t		mp_Size;
4858910Salfred    uintptr_t		mp_Used;
4958910Salfred} MemPool;
5058910Salfred
5167850Sdougb#define MEMNODE_SIZE_MASK       ((sizeof(MemNode) <= 8) ? 7 : 15)
5267850Sdougb
5367850Sdougb#define ZNOTE_FREE	0
5467850Sdougb#define ZNOTE_REUSE	1
5567850Sdougb
5667850Sdougb