Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the ever so important buflib_get_data() wrapper.

  • Loading branch information...
commit bc0781b1e4699680400928fe42e96dac4ae87bf2 1 parent a4f7c1b
@kugel- authored
Showing with 21 additions and 0 deletions.
  1. +5 −0 core_api.c
  2. +16 −0 proposed-api.h
View
5 core_api.c
@@ -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);
View
16 proposed-api.h
@@ -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
*/
Please sign in to comment.
Something went wrong with that request. Please try again.