/* * Copyright (C) 2001-2003 FhG Fokus * * This file is part of Kamailio, a free SIP server. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * \file * \brief Simple, very fast, malloc library * \ingroup mem */ #if defined(F_MALLOC) #if !defined(f_malloc_h) #define f_malloc_h #include "meminfo.h" #ifdef DBG_SR_MEMORY #define DBG_F_MALLOC #endif /** * Use a bitmap to quickly find free fragments, should speed up * especially startup (non-warmed-up malloc) */ #define F_MALLOC_HASH_BITMAP #ifdef DBG_F_MALLOC #if defined(__CPU_sparc64) || defined(__CPU_sparc) /* tricky, on sun in 32 bits mode long long must be 64 bits aligned * but long can be 32 bits aligned => malloc should return long long * aligned memory */ #define ROUNDTO sizeof(long long) #else #define ROUNDTO sizeof(void*) /* size we round to, must be = 2^n, and sizeof(fm_frag) must be multiple of ROUNDTO !*/ #endif #else /* DBG_F_MALLOC */ #define ROUNDTO 8UL #endif #define MIN_FRAG_SIZE ROUNDTO #define F_MALLOC_OPTIMIZE_FACTOR 14UL /* used below */ /** Size to optimize for, (most allocs <= this size), must be 2^k */ #define F_MALLOC_OPTIMIZE (1UL<