内存管理方案 【推荐阅读:图片的平滑切换处理技术】
2. satoria´s malloc——这算是专门为mudos打造的函数库,比大多数系统内建函数要快; 【扩展信息:为您的应用程序建立投影式立体窗口(阴影)】 1. build-in system malloc——系统内建函数库,即malloc,realloc,calloc,free; 3. bsd (berkeley software distributions) malloc——随着freebsd发布出来的malloc源代码,速度应该算是最快的,但会浪费不少内存空间. 定义了至少2套包装(wrap)函数库: 1. wrappedmalloc——简单的对内存分配函数进行了一下包装,提供了有限的内存分配统计功能:内存分配次数(alloc),内存释放次数(free),内存再分配次数(realloc); 2. debugmalloc——正如其名所暗示的:调试期使用的内存分配函数,它的实现比较复杂,不仅提供了安全性检查,而且提供的统计功能也更完善,比如可以查出某次内存分配是为哪种数据类型提供内存空间. 在编译mudos时,通过选择不同的宏定义来选择不同的内存管理方案: /* macro.h */ /* define for malloc, free, realloc, and calloc depend upon what malloc package and optional wrapper is used. this technique is used because overlaying system malloc with another function also named malloc doesn´t work on most mahines that have shared libraries. it will also let us keep malloc stats even when system malloc is used. please refer to options.h for selecting malloc package and wrapper. */ #if (defined(sysmalloc) + defined(smalloc) + defined(bsdmalloc)) > 1 !only one malloc package should be defined #endif #if (defined(wrappedmalloc) + defined(debugmalloc)) > 1 !only one wrapper (at most) should be defined #endif #if defined (wrappedmalloc) && !defined(in_malloc_wrapper) # define malloc(x) wrappedmalloc(x)... 下一页