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; }
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); }
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); }
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; }
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; }
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) {} }
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); }
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); }
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; }
// // 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( <ime ); PrintLogMessage( "[I] Initialization started at: ", ctime( <ime ), 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
/* ================ 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(); }
int main() { assert(Mem_Init(4096) == 0); assert(Mem_Alloc(2048) != NULL); assert(Mem_Alloc(2047) == NULL); exit(0); }
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); }
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); } }
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"); }
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; }
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; }
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); }
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; }
int main() { assert(Mem_Init(4096) == 0); void* ptr = Mem_Alloc(8); assert(ptr != NULL); assert(Mem_Free(ptr) == 0); exit(0); }
int main(void) { OS_ERR err; BSP_IntDisAll(); /* Disable all interrupts. */ CPU_Init(); /* Initialize the uC/CPU Services */ Mem_Init(); /* Initialize Memory Management Module */ Math_Init(); /* Initialize Mathematical Module */ OSInit(&err); /* Init uC/OS-III. */ OSTaskCreate((OS_TCB *)&AppTaskStartTCB, /* Create the start task */ (CPU_CHAR *)"App Task Start", (OS_TASK_PTR )AppTaskStart, (void *)0u, (OS_PRIO )APP_CFG_TASK_START_PRIO, (CPU_STK *)&AppTaskStartStk[0u], (CPU_STK_SIZE )AppTaskStartStk[APP_CFG_TASK_START_STK_SIZE / 10u], (CPU_STK_SIZE )APP_CFG_TASK_START_STK_SIZE, (OS_MSG_QTY )0u, (OS_TICK )0u, (void *)0u, (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *)&err); OSStart(&err); /* Start multitasking (i.e. give control to uC/OS-III). */ (void)&err; return (0u); }
int main() { char *ptr; ptr = (char *)Mem_Init(4096, 64); assert(ptr != NULL); ptr[4095] = 'c'; exit(0); }
/* ================ 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(); // test idPolynomial idPolynomial::Test(); // initialize the dictionary string pools idDict::Init(); }
/* ================ idLib::Init ================ */ void idLib::Init( void ) { assert( sizeof( bool ) == 1 ); // assumptions from the scripting compiler/interpreter assert( sizeof( float ) == sizeof( int ) ); assert( sizeof( idVec3 ) == sizeof( float ) * 3 ); // 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(); // test idPolynomial idPolynomial::Test(); // initialize the dictionary string pools idDict::Init(); }
static void AppTaskStart (void *p_arg) { OS_ERR err; #if (APP_CFG_TCPIP_MODULE_EN > 0u) NET_ERR net_err; #endif (void)&p_arg; BSP_Init(); /* Initialize BSP functions */ CPU_Init(); /* Initialize the uC/CPU services */ OS_CPU_TickInit(); /* Init uC/OS periodic time src (SysTick). */ #if (OS_CFG_STAT_TASK_EN > 0u) OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */ #endif Mem_Init(); /* Initialize mem mgmt module, required for TCP-IP. */ #if (APP_CFG_PROBE_COM_MODULE_EN > 0u) AppProbe_Init(); /* Initialize uC/Probe modules */ #endif OSTaskCreate((OS_TCB *)&AppBlinkyTaskTCB, /* Create the start task */ (CPU_CHAR *)"Blinky Task", (OS_TASK_PTR ) AppBlinkyTask, (void *) 0, (OS_PRIO ) BLINKY_TASK_PRIO, (CPU_STK *)&AppBlinkyTaskStk[0], (CPU_STK_SIZE) BLINKY_TASK_STK_SIZE / 10u, (CPU_STK_SIZE) BLINKY_TASK_STK_SIZE, (OS_MSG_QTY ) 0u, (OS_TICK ) 0u, (void *) 0, (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *)&err); BSP_GraphLCD_Init(); AppGraphLCD_Hdr(); #if (APP_CFG_TCPIP_MODULE_EN > 0u) AppTCPIP_Init(&net_err); /* Initialize uC/TCP-IP & associated applications. */ AppCloud_Init(0); #endif #ifdef CPU_CFG_INT_DIS_MEAS_EN CPU_IntDisMeasMaxCurReset(); #endif AppTCPIP_Cfg = DEF_TRUE; OSTaskDel(&AppTaskStartTCB, /* Delete task because its work is complete */ &err); while (DEF_ON) { ; /* Should not get here! */ } }
int main() { assert(Mem_Init(4096) == 0); assert(Mem_Alloc(4) != NULL); assert(Mem_Alloc(8) != NULL); assert(Mem_Alloc(16) != NULL); assert(Mem_Alloc(4) != NULL); exit(0); }
/** * @brief Setup fixture. */ void setup(void) { Mem_Init(); Fs_Init(FS_NONE); Cmd_Init(); }
/* * @brief Setup fixture. */ void setup(void) { Mem_Init(); Thread_Init(2); memset(&cs, 0, sizeof(cs)); }
int main() { assert(Mem_Init(4096,64) != NULL); char* ptr = (char *)Mem_Alloc(32); assert(ptr != NULL); ptr += 1; assert(Mem_Free(ptr) == -1); exit(0); }
void rtos_init(void) { OS_ERR err; OSInit(&err); Mem_Init(); OSSchedRoundRobinCfg(DEF_ENABLED, 8, &err); }