diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2011-09-07 23:16:29 +0000 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2011-09-07 23:16:29 +0000 |
| commit | 5296af838c39b8b7c4b00a3c896345f9e0719dcf (patch) | |
| tree | e3e31a974f23bd4cd810c00b892c1eabaec4c676 /firmware/include/buflib.h | |
| parent | 6a989b8d4dec4750ad474598bd52897381d2f3cb (diff) | |
| download | rockbox-5296af838c39b8b7c4b00a3c896345f9e0719dcf.zip rockbox-5296af838c39b8b7c4b00a3c896345f9e0719dcf.tar.gz rockbox-5296af838c39b8b7c4b00a3c896345f9e0719dcf.tar.bz2 rockbox-5296af838c39b8b7c4b00a3c896345f9e0719dcf.tar.xz | |
Buflib: Clarification about invalid handles
* Enhance allocation function comments to better state the return value and what an invalid value is
* Change clients to check for "< 0" instead of "<= 0" or "== 0"
* Return -1 or -2 depending on the exact failure in buflib_alloc_ex.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30469 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/include/buflib.h')
| -rw-r--r-- | firmware/include/buflib.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h index db7b5ec..3d8f43e 100644 --- a/firmware/include/buflib.h +++ b/firmware/include/buflib.h @@ -153,7 +153,8 @@ size_t buflib_available(struct buflib_context *ctx); * * size: How many bytes to allocate * - * Returns: An integer handle identifying this allocation + * Returns: A positive integer handle identifying this allocation, or + * a negative value on error (0 is also not a valid handle) */ int buflib_alloc(struct buflib_context *context, size_t size); @@ -166,7 +167,8 @@ int buflib_alloc(struct buflib_context *context, size_t size); * size: How many bytes to allocate * ops: a struct with pointers to callback functions (see above) * - * Returns: An integer handle identifying this allocation + * Returns: A positive integer handle identifying this allocation, or + * a negative value on error (0 is also not a valid handle) */ int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name, struct buflib_callbacks *ops); @@ -188,7 +190,8 @@ int buflib_alloc_ex(struct buflib_context *ctx, size_t size, const char *name, * size: The actual size will be returned into size * ops: a struct with pointers to callback functions * - * Returns: An integer handle identifying this allocation + * Returns: A positive integer handle identifying this allocation, or + * a negative value on error (0 is also not a valid handle) */ int buflib_alloc_maximum(struct buflib_context* ctx, const char* name, size_t *size, struct buflib_callbacks *ops); @@ -233,7 +236,7 @@ bool buflib_shrink(struct buflib_context *ctx, int handle, void* newstart, size_ /** * Frees memory associated with the given handle * - * Returns: 0 (to invalidate handles in one line) + * Returns: 0 (to invalidate handles in one line, 0 is not a valid handle) */ int buflib_free(struct buflib_context *context, int handle); |