signature: add a dup function which takes a pool This will be used by the transaction code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/signature.c b/src/signature.c
index 2a16b48..514b153 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 24655cb..eb71db7 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