diff options
| author | Nakidai <nakidai@disroot.org> | 2024-11-24 19:48:43 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2024-11-24 19:48:43 +0300 |
| commit | 786472f41bc2a7db3bd271fccaaff57fc74b6989 (patch) | |
| tree | c4fa78bb53ce9fe91d0eefdc804217e365241cb9 | |
| parent | a9ae6f4844ae4ac0baa78605157a111aad9358b8 (diff) | |
| download | libhttpc-786472f41bc2a7db3bd271fccaaff57fc74b6989.tar.gz libhttpc-786472f41bc2a7db3bd271fccaaff57fc74b6989.zip | |
Add LibHTTPC_free
| -rw-r--r-- | include/libhttpc.h | 11 | ||||
| -rw-r--r-- | src/libhttpc.c | 7 | ||||
| -rw-r--r-- | src/malloc.c | 5 | ||||
| -rw-r--r-- | src/request.c | 4 |
4 files changed, 19 insertions, 8 deletions
diff --git a/include/libhttpc.h b/include/libhttpc.h index 87f6e6c..6160d21 100644 --- a/include/libhttpc.h +++ b/include/libhttpc.h @@ -16,6 +16,11 @@ typedef void *LibHTTPC_Malloc(size_t); * @see libhttpc_realloc */ typedef void *LibHTTPC_Realloc(void *, size_t); +/** + * Just typedef to make libhttpc_free definition more readable + * @see libhttpc_realloc + */ +typedef void LibHTTPC_Free(void *); /** * Enum that contains all headers that are supported by the HTTP/1.1 @@ -192,13 +197,17 @@ extern LibHTTPC_Malloc *LibHTTPC_malloc; * Realloc used by the library */ extern LibHTTPC_Realloc *LibHTTPC_realloc; +/** + * Free used by the library + */ +extern LibHTTPC_Free *LibHTTPC_free; /** * Setup LibHTTPC_malloc and LibHTTPC_realloc * @param malloc Malloc implementation * @param realloc Realloc implementation */ -void LibHTTPC(LibHTTPC_Malloc *malloc, LibHTTPC_Realloc *realloc); +void LibHTTPC(LibHTTPC_Malloc *malloc, LibHTTPC_Realloc *realloc, LibHTTPC_Free *free); /** * Parse header name diff --git a/src/libhttpc.c b/src/libhttpc.c index 2f700b2..5a39210 100644 --- a/src/libhttpc.c +++ b/src/libhttpc.c @@ -1,8 +1,9 @@ #include "libhttpc.h" -void LibHTTPC(LibHTTPC_Malloc *malloc, LibHTTPC_Realloc *realloc) +void LibHTTPC(LibHTTPC_Malloc *malloc, LibHTTPC_Realloc *realloc, LibHTTPC_Free *free) { - LibHTTPC_malloc = malloc; - LibHTTPC_realloc = realloc; + LibHTTPC_malloc = malloc; + LibHTTPC_realloc = realloc; + LibHTTPC_free = free; } diff --git a/src/malloc.c b/src/malloc.c index a654e31..6287e4a 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -1,5 +1,6 @@ #include "libhttpc.h" -LibHTTPC_Malloc *LibHTTPC_malloc = NULL; -LibHTTPC_Realloc *LibHTTPC_realloc = NULL; +LibHTTPC_Malloc *LibHTTPC_malloc = NULL; +LibHTTPC_Realloc *LibHTTPC_realloc = NULL; +LibHTTPC_Free *LibHTTPC_free = NULL; diff --git a/src/request.c b/src/request.c index 3e017b7..56bf47b 100644 --- a/src/request.c +++ b/src/request.c @@ -74,7 +74,7 @@ struct LibHTTPC_Request *LibHTTPC_loadRequest(struct LibHTTPC_Request *request_b void LibHTTPC_Request_(struct LibHTTPC_Request *request) { if (request->header_selfalloc) - free(request->headers); + LibHTTPC_free(request->headers); if (request->selfalloc) - free(request); + LibHTTPC_free(request); } |