From 57af0b928ec8dd12c443c9479973ad3e39f258b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 19 Aug 2015 00:46:28 +0200 Subject: cred: add a free function wrapper --- include/git2/transport.h | 11 +++++++++++ src/transports/cred.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/include/git2/transport.h b/include/git2/transport.h index fd55eac0a..0ec241699 100644 --- a/include/git2/transport.h +++ b/include/git2/transport.h @@ -307,6 +307,17 @@ GIT_EXTERN(int) git_cred_ssh_key_memory_new( const char *privatekey, const char *passphrase); + +/** + * Free a credential. + * + * This is only necessary if you own the object; that is, if you are a + * transport. + * + * @param cred the object to free + */ +GIT_EXTERN(void) git_cred_free(git_cred *cred); + /** * Signature of a function which acquires a credential object. * diff --git a/src/transports/cred.c b/src/transports/cred.c index 044b2a262..49ede48bf 100644 --- a/src/transports/cred.c +++ b/src/transports/cred.c @@ -378,3 +378,11 @@ int git_cred_username_new(git_cred **cred, const char *username) *cred = (git_cred *) c; return 0; } + +void git_cred_free(git_cred *cred) +{ + if (!cred) + return; + + cred->free(cred); +} -- cgit v1.2.3