diff options
author | Vicent Marti <tanoku@gmail.com> | 2014-08-18 12:41:06 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2014-08-18 12:41:06 +0200 |
commit | 4ca0b566ca811550b4db31045e580b4970e5b8e3 (patch) | |
tree | e34ed66136f5a6cdf496b4d8c8a52fcb9c17702e /include | |
parent | 59403f1ff55346c64bfaa0744ea7f3375da71725 (diff) | |
download | libgit2-4ca0b566ca811550b4db31045e580b4970e5b8e3.tar.gz |
oid: Export `git_oid_tostr_s` instead of `_allocfmt`vmg/tostr_s
The old `allocfmt` is of no use to callers, as they are not able to free
the returned buffer. Export a new API that returns a static string that
doesn't need to be freed.
Diffstat (limited to 'include')
-rw-r--r-- | include/git2/oid.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/git2/oid.h b/include/git2/oid.h index 1cfd4e5e2..db2f3af70 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -116,13 +116,17 @@ GIT_EXTERN(void) git_oid_nfmt(char *out, size_t n, const git_oid *id); GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id); /** - * Format a git_oid into a newly allocated c-string. + * Format a git_oid into a statically allocated c-string. + * + * The c-string is owned by the library and should not be freed + * by the user. If libgit2 is built with thread support, the string + * will be stored in TLS (i.e. one buffer per thread) to allow for + * concurrent calls of the function. * * @param id the oid structure to format - * @return the c-string; NULL if memory is exhausted. Caller must - * deallocate the string with git__free(). + * @return the c-string */ -GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *id); +GIT_EXTERN(char *) git_oid_tostr_s(const git_oid *oid); /** * Format a git_oid into a buffer as a hex format c-string. |