Skip to content

Commit

Permalink
Add the ever so important buflib_get_data() wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Martitz committed Jun 7, 2011
1 parent a4f7c1b commit bc0781b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core_api.c
Expand Up @@ -26,6 +26,11 @@ size_t core_available(void)
return buflib_available(&core_ctx);
}

void* core_get_data(int handle)
{
return buflib_get_data(&core_ctx, handle);
}

void core_free(int handle)
{
buflib_free(&core_ctx, handle);
Expand Down
16 changes: 16 additions & 0 deletions proposed-api.h
Expand Up @@ -37,6 +37,22 @@ int core_alloc(const char* name, size_t size);
struct buflib_callbacks;
int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops);


/**
* Query the data pointer for the given handle. It's actually a cheap operation,
* so don't hesitate using it extensivly.
*
* Notice that you need to re-query after every direct or indirect yield(),
* because compaction can happen by other threads which may get your data
* moved around (or you can get notified about changes by callbacks,
* see further below).
*
* handle: The handle corresponding to the allocation
*
* Returns: The start pointer of the allocation
*/
void* core_get_data(int handle);

/**
* Free memory associated with the given handle
*/
Expand Down

0 comments on commit bc0781b

Please sign in to comment.