mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 02:36:11 +00:00
Implement and use git_pkt_free
A git_pkt object can be one of several structs. Add this function for convenience and clarity. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
ecb6ca0e1f
commit
be9fe679fc
@ -56,3 +56,4 @@ struct git_pkt_ref {
|
||||
*/
|
||||
int git_pkt_gen_proto(char **out, int *outlen, const char *url);
|
||||
int git_pkt_parse_line(git_pkt **head, const char *line, const char **out);
|
||||
void git_pkt_free(git_pkt *pkt);
|
||||
|
11
src/pkt.c
11
src/pkt.c
@ -173,6 +173,17 @@ int git_pkt_parse_line(git_pkt **head, const char *line, const char **out)
|
||||
return error;
|
||||
}
|
||||
|
||||
void git_pkt_free(git_pkt *pkt)
|
||||
{
|
||||
if(pkt->type == GIT_PKT_REF) {
|
||||
git_pkt_ref *p = (git_pkt_ref *) pkt;
|
||||
free(p->capabilities);
|
||||
free(p->head.name);
|
||||
}
|
||||
|
||||
free(pkt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a git procol request.
|
||||
*
|
||||
|
@ -286,12 +286,7 @@ static void git_free(git_transport *transport)
|
||||
|
||||
for (i = 0; i < refs->length; ++i) {
|
||||
git_pkt *p = git_vector_get(refs, i);
|
||||
if (p->type == GIT_PKT_REF) {
|
||||
free(((git_pkt_ref *)p)->head.name);
|
||||
free(((git_pkt_ref *)p)->capabilities);
|
||||
}
|
||||
|
||||
free(p);
|
||||
git_pkt_free(p);
|
||||
}
|
||||
|
||||
git_vector_free(refs);
|
||||
|
Loading…
Reference in New Issue
Block a user