diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-28 07:29:46 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-30 15:44:32 +0200 |
commit | bdeb8772fe846eeeea92cb2d9adb85315f3b8417 (patch) | |
tree | 52cc37d19aa34b1c15b31ceeeb2147edbcca86ba | |
parent | 20363d583cc843f6b7882094ec5077232e03e16a (diff) | |
download | libgit2-bdeb8772fe846eeeea92cb2d9adb85315f3b8417.tar.gz |
signature: add a dup function which takes a pool
This will be used by the transaction code.
-rw-r--r-- | src/signature.c | 24 | ||||
-rw-r--r-- | src/signature.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/signature.c b/src/signature.c index 2a16b484a..514b153ac 100644 --- a/src/signature.c +++ b/src/signature.c @@ -106,6 +106,30 @@ int git_signature_dup(git_signature **dest, const git_signature *source) return 0; } +int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool) +{ + git_signature *signature; + + if (source == NULL) + return 0; + + signature = git_pool_mallocz(pool, sizeof(git_signature)); + GITERR_CHECK_ALLOC(signature); + + signature->name = git_pool_strdup(pool, source->name); + GITERR_CHECK_ALLOC(signature->name); + + signature->email = git_pool_strdup(pool, source->email); + GITERR_CHECK_ALLOC(signature->email); + + signature->when.time = source->when.time; + signature->when.offset = source->when.offset; + + *dest = signature; + + return 0; +} + int git_signature_now(git_signature **sig_out, const char *name, const char *email) { time_t now; diff --git a/src/signature.h b/src/signature.h index 24655cbf5..eb71db7db 100644 --- a/src/signature.h +++ b/src/signature.h @@ -15,4 +15,6 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, const char *buffer_end, const char *header, char ender); void git_signature__writebuf(git_buf *buf, const char *header, const git_signature *sig); +int git_signature__pdup(git_signature **dest, const git_signature *source, git_pool *pool); + #endif |