summaryrefslogtreecommitdiff
path: root/include/git2/buffer.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-09-10 16:33:32 -0700
committerRussell Belfer <rb@github.com>2013-09-17 09:31:44 -0700
commit2a7d224f99a053d93079644947d04e7cc085930f (patch)
tree5a9082e68e98cd85e0bde8d8e399d386158ad390 /include/git2/buffer.h
parent974774c7b00c08585b05ff87174872be005a1f29 (diff)
downloadlibgit2-2a7d224f99a053d93079644947d04e7cc085930f.tar.gz
Extend public filter api with filter lists
This moves the git_filter_list into the public API so that users can create, apply, and dispose of filter lists. This allows more granular application of filters to user data outside of libgit2 internals. This also converts all the internal usage of filters to the public APIs along with a few small tweaks to make it easier to use the public git_buffer stuff alongside the internal git_buf.
Diffstat (limited to 'include/git2/buffer.h')
-rw-r--r--include/git2/buffer.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/include/git2/buffer.h b/include/git2/buffer.h
index 454a1faa5..cb80e48f7 100644
--- a/include/git2/buffer.h
+++ b/include/git2/buffer.h
@@ -21,17 +21,17 @@ GIT_BEGIN_DECL
/**
* A data buffer for exporting data from libgit2
*
- * There are a number of places where libgit2 wants to return an allocated
- * data buffer to the caller and have the caller take ownership of that
- * allocated memory. This can be awkward if the caller does not have easy
- * access to the same allocation functions that libgit2 is using. In those
- * cases, libgit2 will instead fill in a `git_buffer` and the caller can
- * use `git_buffer_free()` to release it when they are done.
+ * Sometimes libgit2 wants to return an allocated data buffer to the
+ * caller and have the caller take responsibility for freeing that memory.
+ * This can be awkward if the caller does not have easy access to the same
+ * allocation functions that libgit2 is using. In those cases, libgit2
+ * will instead fill in a `git_buffer` and the caller can use
+ * `git_buffer_free()` to release it when they are done.
*
* * `ptr` refers to the start of the allocated memory.
* * `size` contains the size of the data in `ptr` that is actually used.
- * * `available` refers to the known total amount of allocated memory in
- * cases where it is larger than the `size` actually in use.
+ * * `available` refers to the known total amount of allocated memory. It
+ * may be larger than the `size` actually in use.
*
* In a few cases, for uniformity and simplicity, an API may populate a
* `git_buffer` with data that should *not* be freed (i.e. the lifetime of
@@ -79,6 +79,17 @@ GIT_EXTERN(void) git_buffer_free(git_buffer *buffer);
*/
GIT_EXTERN(int) git_buffer_resize(git_buffer *buffer, size_t want_size);
+/**
+ * Set buffer to a copy of some raw data.
+ *
+ * @param buffer The buffer to set
+ * @param data The data to copy into the buffer
+ * @param datalen The length of the data to copy into the buffer
+ * @return 0 on success, negative error code on allocation failure
+ */
+GIT_EXTERN(int) git_buffer_copy(
+ git_buffer *buffer, const void *data, size_t datalen);
+
GIT_END_DECL
/** @} */