内存池算法---头文件

/*

 * 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

/******************************************************************************/

/******************************************************************************/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

为毛呀

非常感谢你对我的支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值