Submitter | Iulian Stana |
---|---|
Date | Sept. 18, 2013, 8:42 p.m. |
Message ID | <408d6488f726fc88bba3.1379536952@doppler> |
Download | mbox | patch |
Permalink | /patch/2529/ |
State | Superseded, archived |
Headers | show |
Comments
On Wed, 2013-09-18 at 23:42 +0300, Iulian Stana wrote: > # HG changeset patch > # User Iulian Stana <julian.stana@gmail.com> > # Date 1379451734 -10800 > # Wed Sep 18 00:02:14 2013 +0300 > # Node ID 408d6488f726fc88bba3e64dfcc881f1651f3b91 > # Parent 5f658e94c158620549af557dba47fcab0ba9696f > hg_close: close the connection for the given handle Pushed, thanks. Please use 'hg email -f c-hglib' or similar.
Patch
diff --git a/hglib/client.c b/hglib/client.c --- a/hglib/client.c +++ b/hglib/client.c @@ -168,3 +168,34 @@ handle->out_data_size = 0; return handle; } + +/* Release data from handle pointers. */ +void free_data(hg_handle *handle){ + if (handle->out_data) { + free(handle->out_data); + handle->out_data = NULL; + handle->out_data_size = 0; + } +} + +/* + * Close the connection for the given handle. + * */ +int hg_close(hg_handle **handle) +{ + if (!(*handle)) { + errno = EINVAL; + return -1; + } + + close((*handle)->p_read); + close((*handle)->p_write); + + free((*handle)->header); + free_data(*handle); + free(*handle); + *handle = NULL; + + return 0; +} +