Commit bdeb8772fe846eeeea92cb2d9adb85315f3b8417

Carlos Martín Nieto 2014-06-28T07:29:46

signature: add a dup function which takes a pool This will be used by the transaction code.

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