⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于51的动态内存管理
💻 C
字号:
#include        "ip51_cs_extr.h"                 /* Common service functions  */
#include        "ip51_dm_extr.h"                 /* Dynamic memory functions  */

void main()
{
   unsigned char far  test[0x5000];
   unsigned char far  test1[0x3000];
   
   void *use;
   void *use1;
   void *use2;
   void *use3;
   void *use4;

   xdata IP51_MEMORY_POOL my_memory_pool; //声明一个内存池指针
   xdata IP51_MEMORY_POOL my_memory_pool1; //声明一个内存池指针

   IP51_DMC_Create_Memory_Pool(&my_memory_pool, "wang",
                        test, 0x5000,100);
   IP51_DMC_Create_Memory_Pool(&my_memory_pool1, "wang1",
                        test1, 0x3000,100);


   IP51_DMC_Allocate_Memory(&my_memory_pool, &use,0x1000);
   IP51_DMC_Allocate_Memory(&my_memory_pool, &use1,0x1000);
   IP51_DMC_Allocate_Memory(&my_memory_pool, &use2,0x1000);
   IP51_DMC_Allocate_Memory(&my_memory_pool, &use4,0x1000);
   IP51_DMC_Deallocate_Memory(use1);
   IP51_DMC_Deallocate_Memory(use2);
   //IP51_DMC_Deallocate_Memory(use4);
   
   if(IP51_DMC_Allocate_Memory(&my_memory_pool, &use3,0x2000) == IP51_NO_MEMORY)
   {
      IP51_DMC_Allocate_Memory(&my_memory_pool, &use3,0x1000);
   }

   IP51_DMC_Delete_Memory_Pool(&my_memory_pool);
   IP51_DMC_Allocate_Memory(&my_memory_pool, &use2,0x2000);
   
   while(1);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -