diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-05-28 10:56:19 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-06-26 18:18:12 +0200 |
| commit | 1d27446c603cbad306a8f294fb835ed3db8697b9 (patch) | |
| tree | 8200af32320e92cbfb7c8584f76639594f576868 | |
| parent | f7fc68df832439c3e2355ab747fa05a8b46aa8d0 (diff) | |
| download | libgit2-1d27446c603cbad306a8f294fb835ed3db8697b9.tar.gz | |
Move flush-pkt creation into its own function
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
| -rw-r--r-- | src/pkt.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -30,6 +30,20 @@ #include "common.h" #include "util.h" +static int flush_pkt(git_pkt **out) +{ + git_pkt *pkt; + + pkt = git__malloc(sizeof(git_pkt)); + if (pkt == NULL) + return GIT_ENOMEM; + + pkt->type = GIT_PKT_FLUSH; + *out = pkt; + + return GIT_SUCCESS; +} + /* * As per the documentation, the syntax is: * @@ -54,24 +68,19 @@ int git_pkt_parse_line(git_pkt **head, const char *line, const char **out) if (error < GIT_SUCCESS) return error; + line = num_end; /* * TODO: How do we deal with empty lines? Try again? with the next * line? */ if (len == 4) { - *out = num_end; + *out = line; return GIT_SUCCESS; } - if (len == 0) { /* Flush, should go into its own fn */ - pkt = git__malloc(sizeof(git_pkt)); - if (pkt == NULL) - return GIT_ENOMEM; - - pkt->type = GIT_PKT_FLUSH; - *head = pkt; - *out = num_end; - return GIT_SUCCESS; + if (len == 0) { /* Flush pkt */ + *out = line; + return flush_pkt(head); } /* TODO: Write the rest of this thing */ |
