当前位置: 首页>>代码示例>>C++>>正文


C++ Mem_Init函数代码示例

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


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


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