diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-14 14:44:53 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-04-14 14:58:14 (EDT) |
commit | f9dafad4a195adec937c72f825aaecdcabfec8d7 (patch) | |
tree | 7704d3a7c730f982ae7dcb3c4f670e1389aef99b /src | |
parent | ea566435355699cab1d3db3343cf6996c281f2f2 (diff) |
gzip, ustar: Add *_free() functions
Diffstat (limited to 'src')
-rw-r--r-- | src/gzip.c | 10 | ||||
-rw-r--r-- | src/gzip.h | 3 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/ustar.c | 7 | ||||
-rw-r--r-- | src/ustar.h | 3 |
5 files changed, 22 insertions, 6 deletions
@@ -71,7 +71,6 @@ opkg_opk_gzip_read(struct opkg_opk_gzip *gzip, void *record) break; case OPKG_OPK_ERROR: default: - inflateEnd(&gzip->stream); return OPKG_OPK_ERROR; } } @@ -84,11 +83,16 @@ opkg_opk_gzip_read(struct opkg_opk_gzip *gzip, void *record) case Z_BUF_ERROR: break; case Z_STREAM_END: - inflateEnd(&gzip->stream); return OPKG_OPK_END; default: - inflateEnd(&gzip->stream); return OPKG_OPK_ERROR; } } } + +void +opkg_opk_gzip_free(struct opkg_opk_gzip *gzip) +{ + inflateEnd(&gzip->stream); + free(gzip); +} @@ -28,4 +28,7 @@ opkg_opk_gzip_init(int (*read)(void *, char **, size_t *), void *user_data); int opkg_opk_gzip_read(struct opkg_opk_gzip *gzip, void *record); +void +opkg_opk_gzip_free(struct opkg_opk_gzip *gzip); + #endif /* OPKG_OPK_GZIP_H_ */ @@ -64,14 +64,15 @@ main(int argc, char *argv[]) } ustar = opkg_opk_ustar_init(gzip); if (ustar == NULL) { - /* TODO: Free gzip. */ + opkg_opk_gzip_free(gzip); fclose(file.file); return EXIT_FAILURE; } while ((ret = opkg_opk_ustar_list(ustar, &member)) == OPKG_OPK_OK) { puts(member.name); } - /* TODO: Free ustar and gzip. */ + opkg_opk_gzip_free(gzip); + opkg_opk_ustar_free(ustar); fclose(file.file); return EXIT_SUCCESS; diff --git a/src/ustar.c b/src/ustar.c index 69071c7..4805880 100644 --- a/src/ustar.c +++ b/src/ustar.c @@ -82,7 +82,6 @@ _opkg_opk_ustar_next(struct opkg_opk_ustar *ustar, } memset(record, 0, 512); if (memcmp(header, record, 512) == 0) { - /* TODO: End gzip stream */ return OPKG_OPK_END; } if (memcmp(header->magic, "ustar", strlen("ustar")) != 0) { @@ -192,3 +191,9 @@ opkg_opk_ustar_read(struct opkg_opk_ustar *ustar, char *buffer, size_t *size) } return OPKG_OPK_OK; } + +void +opkg_opk_ustar_free(struct opkg_opk_ustar *ustar) +{ + free(ustar); +} diff --git a/src/ustar.h b/src/ustar.h index a1c5e75..ccb10a2 100644 --- a/src/ustar.h +++ b/src/ustar.h @@ -39,4 +39,7 @@ opkg_opk_ustar_seek(struct opkg_opk_ustar *ustar, const char *member); int opkg_opk_ustar_read(struct opkg_opk_ustar *ustar, char *buffer, size_t *size); +void +opkg_opk_ustar_free(struct opkg_opk_ustar *ustar); + #endif /* OPKG_OPK_USTAR_H_ */ |