00001 00384 //-------------------------------------------------------------------------------------------------- 00393 #ifndef LEGATO_MEM_INCLUDE_GUARD 00394 #define LEGATO_MEM_INCLUDE_GUARD 00395 00396 //-------------------------------------------------------------------------------------------------- 00401 //-------------------------------------------------------------------------------------------------- 00402 typedef struct le_mem_Pool* le_mem_PoolRef_t; 00403 00404 00405 //-------------------------------------------------------------------------------------------------- 00417 //-------------------------------------------------------------------------------------------------- 00418 typedef void (*le_mem_Destructor_t) 00419 ( 00420 void* objPtr 00421 ); 00422 00423 00424 //-------------------------------------------------------------------------------------------------- 00428 //-------------------------------------------------------------------------------------------------- 00429 typedef struct 00430 { 00431 uint64_t numAllocs; 00432 size_t numFree; 00433 size_t numOverflows; 00434 } 00435 le_mem_PoolStats_t; 00436 00437 00438 //-------------------------------------------------------------------------------------------------- 00449 //-------------------------------------------------------------------------------------------------- 00450 le_mem_PoolRef_t le_mem_CreatePool 00451 ( 00452 const char* name, 00453 size_t objSize 00454 00455 ); 00456 00457 00458 //-------------------------------------------------------------------------------------------------- 00467 //-------------------------------------------------------------------------------------------------- 00468 le_mem_PoolRef_t le_mem_ExpandPool 00469 ( 00470 le_mem_PoolRef_t pool, 00471 size_t numObjects 00472 ); 00473 00474 00475 //-------------------------------------------------------------------------------------------------- 00483 //-------------------------------------------------------------------------------------------------- 00484 void* le_mem_TryAlloc 00485 ( 00486 le_mem_PoolRef_t pool 00487 ); 00488 00489 00490 //-------------------------------------------------------------------------------------------------- 00500 //-------------------------------------------------------------------------------------------------- 00501 void* le_mem_AssertAlloc 00502 ( 00503 le_mem_PoolRef_t pool 00504 ); 00505 00506 00507 //-------------------------------------------------------------------------------------------------- 00517 //-------------------------------------------------------------------------------------------------- 00518 void* le_mem_ForceAlloc 00519 ( 00520 le_mem_PoolRef_t pool 00521 ); 00522 00523 00524 //-------------------------------------------------------------------------------------------------- 00534 //-------------------------------------------------------------------------------------------------- 00535 void le_mem_SetNumObjsToForce 00536 ( 00537 le_mem_PoolRef_t pool, 00538 size_t numObjects 00539 00540 ); 00541 00542 00543 //-------------------------------------------------------------------------------------------------- 00557 //-------------------------------------------------------------------------------------------------- 00558 void le_mem_Release 00559 ( 00560 void* objPtr 00561 ); 00562 00563 00564 //-------------------------------------------------------------------------------------------------- 00573 //-------------------------------------------------------------------------------------------------- 00574 void le_mem_AddRef 00575 ( 00576 void* objPtr 00577 ); 00578 00579 00580 //-------------------------------------------------------------------------------------------------- 00589 //-------------------------------------------------------------------------------------------------- 00590 void le_mem_SetDestructor 00591 ( 00592 le_mem_PoolRef_t pool, 00593 le_mem_Destructor_t destructor 00594 ); 00595 00596 00597 //-------------------------------------------------------------------------------------------------- 00604 //-------------------------------------------------------------------------------------------------- 00605 void le_mem_GetStats 00606 ( 00607 le_mem_PoolRef_t pool, 00608 le_mem_PoolStats_t* statsPtr 00609 ); 00610 00611 00612 //-------------------------------------------------------------------------------------------------- 00619 //-------------------------------------------------------------------------------------------------- 00620 void le_mem_ResetStats 00621 ( 00622 le_mem_PoolRef_t pool 00623 ); 00624 00625 00626 //-------------------------------------------------------------------------------------------------- 00634 //-------------------------------------------------------------------------------------------------- 00635 size_t le_mem_GetTotalNumObjs 00636 ( 00637 le_mem_PoolRef_t pool 00638 ); 00639 00640 00641 //-------------------------------------------------------------------------------------------------- 00648 //-------------------------------------------------------------------------------------------------- 00649 size_t le_mem_GetObjectSize 00650 ( 00651 le_mem_PoolRef_t pool 00652 ); 00653 00654 00655 //-------------------------------------------------------------------------------------------------- 00662 //-------------------------------------------------------------------------------------------------- 00663 le_mem_PoolRef_t le_mem_FindPool 00664 ( 00665 const char* name 00666 ); 00667 00668 00669 //-------------------------------------------------------------------------------------------------- 00679 //-------------------------------------------------------------------------------------------------- 00680 le_mem_PoolRef_t le_mem_CreateSubPool 00681 ( 00682 le_mem_PoolRef_t superPool, 00683 const char* name, 00684 00685 size_t numObjects 00686 ); 00687 00688 00689 //-------------------------------------------------------------------------------------------------- 00698 //-------------------------------------------------------------------------------------------------- 00699 void le_mem_DeleteSubPool 00700 ( 00701 le_mem_PoolRef_t subPool 00702 ); 00703 00704 00705 #endif // LEGATO_MEM_INCLUDE_GUARD