X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/03e948b1af5e17259fb1da0acff9902604ac1b5f..1e50f983ddb9aaebfc7215884143433a23e21b8e:/libupkg.c diff --git a/libupkg.c b/libupkg.c index b932d86..de4b2f1 100644 --- a/libupkg.c +++ b/libupkg.c @@ -6,7 +6,7 @@ #include "pack.h" struct upkg_name { - unsigned long index, flags; + unsigned long flags; char *name; }; @@ -19,16 +19,6 @@ struct upkg_private { unsigned char guid[16]; }; -static int namecmp(const void *_a, const void *_b, void *_pkg) -{ - const struct upkg_name *a = _a, *b = _b; - if (a->index < b->index) - return -1; - if (a->index > b->index) - return -1; - return 0; -} - static long decode_index(unsigned char *bytes) { long val = 0; @@ -73,7 +63,7 @@ static struct upkg *init_upkg(unsigned char hdr[static UPKG_HDR_SIZE]) static int pkg_init_names(struct upkg *pkg) { - size_t rc, nbuf = 0, len; + size_t rc, len, nbuf = 0; unsigned long index = 0; char buf[512]; @@ -86,7 +76,6 @@ static int pkg_init_names(struct upkg *pkg) while (index < pkg->name_count) { struct upkg_name *name = &pkg->priv->names[index]; - name->index = index; /* Read some data into buffer. */ if (!feof(pkg->priv->f)) { @@ -110,12 +99,15 @@ static int pkg_init_names(struct upkg *pkg) memmove(buf, buf+len+5, nbuf); index++; } else { + /* TODO */ abort(); } } return 0; err: + for (unsigned i = 0; i < index; i++) + free(pkg->priv->names[i].name); free(pkg->priv->names); return -1; }