pavel-kirienko / o1heap

Constant-complexity deterministic memory allocator (heap) for hard real-time high-integrity embedded systems. There is very little activity because the project is finished and does not require further changes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

provide an error code out argument for o1heapInit

thirtytwobits opened this issue · comments

int error_code = O1HEAP_NO_ERROR;
O1HeapInstance* h = o1heapInit(my_buffer, my_buffer_size, &error_code);

if (error_code == O1HEAP_ERR_BASE_TOO_SMALL)
{
    throw my_buffer_too_small_exception();
}

etc.

There are no other error cases so having an error code will add no new information to the user.

I take that back. There are two error cases: bad alignment and the arena being too small. Does this justify the existence of a separate argument?

I'm struggling to figure out what I'm doing wrong right now so...yes?

Can I name the error code argument after you?

perhaps if you provided a way to query the required minimum size then you can document that the failure is either that or that the pointer was not aligned per O1HEAP_ALIGNMENT.