• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Mem_Init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Mem_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ Mem_Init函数的具体用法?C++ Mem_Init怎么用?C++ Mem_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Mem_Init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char * argv[]) {

    int init = Mem_Init(5120, 0);
    printf("init value is %d\n", init);
    int init1 = Mem_Init(-1, 0);
    printf("init1 value is %d\n", init1);

    return 0;
}
开发者ID:kah2011,项目名称:cs537,代码行数:9,代码来源:mem.c


示例2: main

int main() {
   char *ptr = (char *)Mem_Init(4096, 64);
   assert(ptr != NULL);
   int i = 0;
   char *nfPtr,*nfPtr1,*nfPtr2,*nfPtr3;
   for(i=0; i<32; i++)
   {
   	nfPtr = (char *)Mem_Alloc(32);
	assert(nfPtr != NULL);
	assert(nfPtr-ptr-sizeof(struct AllocatedHeader) >= 1024);
	if (i == 13)
		nfPtr1 = nfPtr;
	else if (i == 23)
		nfPtr2 = nfPtr;
   }
   assert(Mem_Free(nfPtr1) == 0);
   assert(Mem_Free(nfPtr2) == 0);

   nfPtr3 = (char *)Mem_Alloc(32);
   assert(nfPtr3 != NULL);
   assert(nfPtr3-ptr-sizeof(struct AllocatedHeader) >= 1024);

   assert((nfPtr + 32 + sizeof(struct AllocatedHeader)) == nfPtr3);
   exit(0);
}
开发者ID:Aarskin,项目名称:CS537,代码行数:25,代码来源:verify_nextfit.c


示例3: main

int main()
{
  /* Create memory space */
  assert(Mem_Init(MEM_SIZE) == 0);
  printf("Memory Space requested with size: %d\n",MEM_SIZE);   
  Mem_Dump();  

  /* Ask for simple memory allocation */
  void* ptr = Mem_Alloc(ALLOC_SIZE);
  printf("\nRequest memory block of size: %d\n",ALLOC_SIZE);
  Mem_Dump();
 
  /* Free memory */
  assert(Mem_Free(ptr) == 0);
  printf("\nFree memory space");
  Mem_Dump();
  
  /* Request memory again*/
  ptr = Mem_Alloc(ALLOC_SIZE);
  printf("\nRequest memory block of size: %d\n",ALLOC_SIZE);
  Mem_Dump();
    
  /* Corrupt pointer */
  ptr = NULL;

  /* Attemp to free memory with bad pointer */
  int result = Mem_Free(ptr);
  printf("Attempted to free memory pointed to by pointer (ptr = %p)\n",ptr);
  printf("Result from Mem_Free(ptr) = %d\n",result);
  Mem_Dump();

  exit(0);
}
开发者ID:gzachv,项目名称:ece354,代码行数:33,代码来源:freetests.c


示例4: main

int
main(int argc, char *argv[]) {
//   int rc = Mem_Init(2000, 2);
//   printf("the return code was: %d\n", rc);
//   printf("merror: %d\n", rc);
//   Mem_Dump();
//   printf("Malloc:\n");
//   void *a = Mem_Alloc(10);
//   void *b = Mem_Alloc(30);
//   void *c = Mem_Alloc(80);
//   Mem_Dump();
//   printf("Free:\n");
//   printf("Free a\n");
//   Mem_Free(a);
//   printf("Free c\n");
//   Mem_Free(c);
//   printf("Free b\n");
//   Mem_Free(b);
//   Mem_Dump();
  
   assert(Mem_Init(4096, 0) == 0);
   assert(Mem_Alloc(1) != NULL);
   assert(Mem_Alloc(5) != NULL);
   assert(Mem_Alloc(14) != NULL);
   assert(Mem_Alloc(8) != NULL);
   assert(Mem_Alloc(1) != NULL);
   assert(Mem_Alloc(4) != NULL);
   assert(Mem_Alloc(9) != NULL);
   assert(Mem_Alloc(33) != NULL);
   assert(Mem_Alloc(55) != NULL);
  return 0;
}
开发者ID:Sandesh-bn,项目名称:Homework,代码行数:32,代码来源:mymain.c


示例5: main

int main(int argc, char *argv[]) {
  void *space = Mem_Init(4096);
  assert(space != NULL);
  printf("Got space %p\n", space);
  int *x = Mem_Alloc(sizeof(int));
  //int *y = Mem_Alloc(sizeof(int));
  //assert(x != NULL && y != NULL);

  //printf("pre x = %p\n", x);
  //printf("pre y = %p\n", y);

  // use x and y
  *x = 123;
  //*y = 456;

  //printf("post x = %p\n", x);
  //printf("post y = %p\n", y);

  //Mem_Free(x);
  //Mem_Free(y);

  //int64_t *x;
  // should loop forever
  
  while ((x = Mem_Alloc(sizeof(int))) != NULL) {
    printf("x = %p\n", x);
    //Mem_Free(x);
    //Mem_Dump();
  }

  Mem_Dump();
  return 0;
}
开发者ID:TheRyanKing87,项目名称:Memory-allocator,代码行数:33,代码来源:tester.c


示例6: main

int main(void)
{
    OS_ERR   err;
    int i;

    HAL_Init();                                                 /* See Note 1.                                          */
    Mem_Init();                                                 /* Initialize Memory Managment Module                   */
    Math_Init();                                                /* Initialize Mathematical Module                       */
    BSP_IntDisAll();                                            /* Disable all Interrupts.                              */
    App_OS_SetAllHooks();

    OSInit(&err);                                               /* Init uC/OS-III.                                      */


    for(i = 0; i < APP_THREAD_COUNT-1; i++)
        sem_init(&g_thread_startup[i], 0, 0);
    sem_init(&g_sem_debug, 0, 1);
    g_debug_tx_buffer = mq_open(0, 512);

    pthread_attr_setstacksize(&g_thread_attr[0], 1024*2);
    pthread_create(&g_thread[0], &g_thread_attr[0], Thread_Startup, 0);
    pthread_setschedprio(&g_thread[0], 1);

    DEFINE_THREAD(Thread_DebugTX, 1024,   1);
    DEFINE_THREAD(Thread_DebugRx, 1024,   1);
    DEFINE_THREAD(Thread_RFIntr,  1024,   3);
    DEFINE_THREAD(Thread_MiwiTask,1024*5, 4);

    OSStart(&err);                                              /* Start multitasking (i.e. give control to uC/OS-III). */

    while (1) {}
}
开发者ID:binhfile,项目名称:stm32,代码行数:32,代码来源:app.c


示例7: main

int main() {
   assert(Mem_Init(4096) == 0);
   void * ptr[4];

   ptr[0] = Mem_Alloc(800);
   assert(ptr[0] != NULL);

   ptr[1] = Mem_Alloc(800);
   assert(ptr[1] != NULL);

   ptr[2] = Mem_Alloc(800);
   assert(ptr[2] != NULL);

   ptr[3] = Mem_Alloc(800);
   assert(ptr[3] != NULL);

   while (Mem_Alloc(800) != NULL)
      ;

   assert(Mem_Free(ptr[1]) == 0);
   assert(Mem_Free(ptr[2]) == 0);

   ptr[2] = Mem_Alloc(1600);
   assert(ptr[2] != NULL);

   exit(0);
}
开发者ID:markcoatsworth,项目名称:CS537,代码行数:27,代码来源:coalesce.c


示例8: main

int main() {
   assert(Mem_Init(4096) == 0);
   void *ptr[4];
   void *first, *best, *worst;

   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   ptr[0] = Mem_Alloc(40, FIRSTFIT);
   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   ptr[1] = Mem_Alloc(56, FIRSTFIT);
   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   first = Mem_Alloc(256, FIRSTFIT);
   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   best = Mem_Alloc(128, FIRSTFIT);
   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   ptr[2] = Mem_Alloc(32, FIRSTFIT);
   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   worst = Mem_Alloc(512, FIRSTFIT);
   assert(Mem_Alloc(8, FIRSTFIT) != NULL);
   ptr[3] = Mem_Alloc(32, FIRSTFIT);

   while(Mem_Alloc(128, FIRSTFIT) != NULL);
   assert(m_error == E_NO_SPACE);

   assert(Mem_Free(ptr[2]) == 0);
   assert(Mem_Free(ptr[3]) == 0);
   assert(Mem_Free(first) == 0);
   assert(Mem_Free(best) == 0);
   assert(Mem_Free(ptr[1]) == 0);
   assert(Mem_Free(worst) == 0);
   assert(Mem_Free(ptr[0]) == 0);

   assert(Mem_Alloc(128, BESTFIT) == best);

   exit(0);
}
开发者ID:asegid,项目名称:cs537,代码行数:35,代码来源:bestfit2.c


示例9: main

int main(int argc, char* argv[]) {
    /*FILE* fd = fopen("code.bin", "rb");
    size_t size = fread(code, 1, sizeof(code), fd);
    fclose(fd);*/

	//citra hacks

	EmuWindow_GLFW window;

	VideoCore::Init(&window);

	//citra hacks end

    //MainWindow* wndMain = new MainWindow();
	mykernel = new KKernel();

    Mem_Init(false);
    Mem_SharedMemInit();

	Boot(mykernel);

    //kernel->AddQuickCodeProcess(&code[0], size);
    mykernel->ThreadsRunTemp();
    return 0;
}
开发者ID:Christchex,项目名称:XDS,代码行数:25,代码来源:Main.cpp


示例10: _InitModem

//
//  Function:       _InitModem
//
//  Description:    Initialization of Radio Modem
//
//  Return Values:
//
//  Name        Explanation
//  ----------- -------------------------------------------------------------------
//  RetStatus    Error code
//
int _InitModem( t_boolean FirstTime )
{
  int       RetStatus     = RM_SUCCESS;
  time_t      ltime;

  HeapBuffDef *pHeap      = Data_GetHeapPtr();
  pHeap->DataLength      = 0;           //Initialization of Main Heap Buffer

  RM_InitPrint( "ErrorRM.txt" ); //I need to put here fileName of error log file

  time( &ltime );
  PrintLogMessage( "[I] Initialization started at: ", ctime( &ltime ), 0 );

  //Initialization of internal memory manager
  if ( (RetStatus = Mem_Init( FirstTime )) != RM_SUCCESS )
    PrintError( "[E] InitModem ( Memory Error )", "RetStatus:", RetStatus ); 

  //Initialization of internal queues
  QueueInit(FirstTime); 

#ifdef RM_STANDALONE
  Uart_Init();
#endif

  if ( (RetStatus = VRM_Init(UNCONFIRMED)) == RM_SUCCESS )
    PrintError( "InitModem: COMPLETED", "", 0 ); 
  else
  {
    PrintError( "InitModem: FATAL ERROR", "Power cycle your modem. RetStatus:", RetStatus ); 
  }//end else

  return( RetStatus );
}//RM_InitModem
开发者ID:bochaqos,项目名称:tol,代码行数:44,代码来源:InitUtil.c


示例11: assert

/*
================
idLib::Init
================
*/
void idLib::Init( void ) {

    assert( sizeof( bool ) == 1 );

    // initialize little/big endian conversion
    Swap_Init();

    // initialize memory manager
    Mem_Init();

    // init string memory allocator
    idStr::InitMemory();

    // initialize generic SIMD implementation
    idSIMD::Init();

    // initialize math
    idMath::Init();

    // test idMatX
    //idMatX::Test();

#if !HUMANHEAD	// HUMANHEAD pdm: Don't bother testing id's unused polynomial code
    // test idPolynomial
    idPolynomial::Test();
#endif

    // initialize the dictionary string pools
    idDict::Init();
}
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:35,代码来源:Lib.cpp


示例12: main

int main() {
   assert(Mem_Init(4096) == 0);
   assert(Mem_Alloc(2048) != NULL);
   assert(Mem_Alloc(2047) == NULL);

   exit(0);
}
开发者ID:alexfaber2011,项目名称:kosher,代码行数:7,代码来源:alloc2_nospace.c


示例13: main

int main() {
   assert(Mem_Init(4096) == 0);
   void * ptr[4];

   ptr[0] = Mem_Alloc(800, FIRSTFIT);
   assert(ptr[0] != NULL);

   ptr[1] = Mem_Alloc(800, FIRSTFIT);
   assert(ptr[1] != NULL);

   ptr[2] = Mem_Alloc(800, FIRSTFIT);
   assert(ptr[2] != NULL);

   ptr[3] = Mem_Alloc(800, FIRSTFIT);
   assert(ptr[3] != NULL);

   while (Mem_Alloc(800, FIRSTFIT) != NULL)
      ;

   assert(m_error == E_NO_SPACE);

   assert(Mem_Free(ptr[2]) == 0);
   assert(Mem_Free(ptr[1]) == 0);

   ptr[2] = Mem_Alloc(1600, FIRSTFIT);
   assert(ptr[2] != NULL);

   exit(0);
}
开发者ID:asegid,项目名称:cs537,代码行数:29,代码来源:coalesce2.c


示例14: AppTaskStart

static  void  AppTaskStart (void *p_arg)
{
   (void)p_arg;

    BSP_Init();                                                 /* Initialize BSP functions                             */
    CPU_Init();                                                 /* Initialize the uC/CPU services                       */
    
    BSP_Tick_Init();                                            /* Start Tick Initialization                            */

    Mem_Init();                                                 /* Initialize memory managment module                   */
    Math_Init();                                                /* Initialize mathematical module                       */


#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                               */
#endif

    BSP_LED_Off(0);
    
#if (APP_CFG_SERIAL_EN == DEF_ENABLED)    
    App_SerialInit();                                           /* Initialize Serial communication for application ...  */
#endif

    APP_TRACE_INFO(("Creating Application Events...\n\r"));
    AppEventCreate();                                          /* Create Application Events                            */

    APP_TRACE_INFO(("Creating Application Tasks...\n\r"));
    AppTaskCreate();                                           /* Create application tasks                             */
    
    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.       */
        BSP_LED_Toggle(0);
        OSTimeDlyHMSM(0, 0, 0, 100);
    }
}
开发者ID:ptracton,项目名称:experimental,代码行数:34,代码来源:app.c


示例15: TEST_Init

void TEST_Init (void)
{
	try {
		com_aliasSysPool  = Mem_CreatePool("Common: Alias system");
		com_cmdSysPool    = Mem_CreatePool("Common: Command system");
		com_cmodelSysPool = Mem_CreatePool("Common: Collision model");
		com_cvarSysPool   = Mem_CreatePool("Common: Cvar system");
		com_fileSysPool   = Mem_CreatePool("Common: File system");
		com_genericPool   = Mem_CreatePool("Generic");

		Mem_Init();
		Cbuf_Init();
		Cmd_Init();
		Cvar_Init();
		FS_InitFilesystem(true);
		FS_AddGameDirectory("./unittest", false);
		FS_AddHomeAsGameDirectory("unittest", true);
		Swap_Init();
		SV_Init();
		NET_Init();

		FS_ExecAutoexec();

		OBJZERO(csi);
	} catch (comDrop_t const&) {
		Sys_Error("Error during initialization");
	}

	http_timeout = Cvar_Get("noname");
	http_proxy = Cvar_Get("noname");
	hwclass = Cvar_Get("hwclass", "5");
}
开发者ID:chagara,项目名称:ufoai,代码行数:32,代码来源:test_shared.cpp


示例16: main

int main (int argc, char **argv)
{
    char bspFilename[MAX_OSPATH];

    if (argc < 2) {
        Usage();
    }

    com_genericPool = Mem_CreatePool("slicer");
    com_fileSysPool = Mem_CreatePool("slicer filesys");

    Swap_Init();
    Mem_Init();

    SL_Parameter(argc, argv);

    Com_StripExtension(config.filename, bspFilename, sizeof(bspFilename));
    Com_DefaultExtension(bspFilename, sizeof(bspFilename), ".bsp");

    FS_InitFilesystem(false);
    SL_BSPSlice(LoadBSPFile(bspFilename), config.thickness, config.scale, config.singleContour, config.multipleContour);

    Mem_Shutdown();

    return EXIT_SUCCESS;
}
开发者ID:Qazzian,项目名称:ufoai_suspend,代码行数:26,代码来源:ufoslicer.cpp


示例17: __MLoad_Initialize

s32 __MLoad_Initialize(u32 *queuehandle)
{
	void *buffer = NULL;
	s32   ret;

	/* Initialize memory heap */
	Mem_Init();

	/* Initialize timer subsystem */
	Timer_Init();

	/* Allocate queue buffer */
	buffer = Mem_Alloc(0x20);
	if (!buffer)
		return IPC_ENOMEM;

	/* Create message queue */
	ret = os_message_queue_create(buffer, 8);
	if (ret < 0)
		return ret;

	/* Enable PPC HW access */
	os_ppc_access(1);

	/* Software interrupt */
	os_software_IRQ(9);

	/* Register devices */
	os_device_register(DEVICE_NAME, ret);

	/* Copy queue handler */
	*queuehandle = ret;

	return 0;
}
开发者ID:shadowbladeZ,项目名称:mload-module,代码行数:35,代码来源:main.c


示例18: TEST_Init

void TEST_Init (void)
{
	Com_SetExceptionCallback(Test_InitError);

	com_aliasSysPool = Mem_CreatePool("Common: Alias system");
	com_cmdSysPool = Mem_CreatePool("Common: Command system");
	com_cmodelSysPool = Mem_CreatePool("Common: Collision model");
	com_cvarSysPool = Mem_CreatePool("Common: Cvar system");
	com_fileSysPool = Mem_CreatePool("Common: File system");
	com_genericPool = Mem_CreatePool("Generic");

	Mem_Init();
	Cbuf_Init();
	Cmd_Init();
	Cvar_Init();
	FS_InitFilesystem(qtrue);
	FS_AddGameDirectory("./unittest", qfalse);
	Swap_Init();
	SV_Init();
	NET_Init();

	FS_ExecAutoexec();

	OBJZERO(csi);

	Com_SetExceptionCallback(Test_RunError);

	http_timeout = Cvar_Get("noname", "", 0, NULL);
	http_proxy = Cvar_Get("noname", "", 0, NULL);
}
开发者ID:kevlund,项目名称:ufoai,代码行数:30,代码来源:test_shared.c


示例19: __SDHC_Initialize

s32 __SDHC_Initialize(u32 *queuehandle)
{
	void *buffer = NULL;
	s32   ret;

	/* Initialize memory heap */
	Mem_Init();

	/* Initialize timer subsystem */
	Timer_Init();

	/* Allocate queue buffer */
	buffer = Mem_Alloc(0x80);
	if (!buffer)
		return IPC_ENOMEM;

	/* Create message queue */
	ret = os_message_queue_create(buffer, 32);
	if (ret < 0)
		return ret;

	/* Register devices */
	os_device_register(DEVICE_NAME, ret);

	/* Copy queue handler */
	*queuehandle = ret;

	return 0;
}
开发者ID:kenji-tan,项目名称:sdhc-module,代码行数:29,代码来源:main.c


示例20: main

int main() {
   assert(Mem_Init(4096) == 0);
   void* ptr = Mem_Alloc(8);
   assert(ptr != NULL);
   assert(Mem_Free(ptr) == 0);
   exit(0);
}
开发者ID:markcoatsworth,项目名称:CS537,代码行数:7,代码来源:free_simple.c



注:本文中的Mem_Init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Memcpy函数代码示例发布时间:2022-05-30
下一篇:
C++ Mem_Free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap