/*
* The young Library
* Copyright (c) 2005 by Yang Huan(杨桓)
* Permission to use, copy, modify, distribute and sell this software for any
* purpose is hereby granted without fee, provided that the above copyright
* notice appear in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation.
* The author make no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
*/
/******************************************************************************/
/******************************************************************************/
#ifndef __MACRO_C_YOUNG_LIBRARY_MEMORY_FUNCTION_HEADER_FILE__
#define __MACRO_C_YOUNG_LIBRARY_MEMORY_FUNCTION_HEADER_FILE__
/******************************************************************************/
#include "yc_definition.h"
#ifdef __cplusplus
namespace youngc { extern "C" {
#endif
/******************************************************************************/
/******************************************************************************/
/* 返回 element_size 对齐后的字节数 */
size_t memalign( size_t element_size, bool memory_type );
/* 获取内存池的链数 */
size_t get_pool_lists_count( void );
/* 获取内存池执行分配的次数 */
size_t get_pool_alloc_count( void );
/* 获取内存池执行归还的次数 */
size_t get_pool_dealloc_count( void );
/* 设置在并行系统中使用的加锁函数 */
void set_pool_lock( void (*lock)(size_t index) );
/* 设置在并行系统中使用的解锁函数 */
void set_pool_unlock( void (*unlock)(size_t index) );
/* 打印内存池 */
void pool_print( void );
/* 从内存池中申请至少 bytes 个字节的内存块 */
void* pool_alloc( size_t bytes );
/* 只将内存块回收至内存池 */
void pool_dealloc( void* ptr, size_t bytes );
/* 先将内存块回收至内存池,再将内存池中空闲的内存页释放 */
void pool_free( void* ptr, size_t bytes );
/******************************************************************************/
/******************************************************************************/
#ifdef __cplusplus
} }
#endif
#endif
/******************************************************************************/
/******************************************************************************/