better names
--HG--
branch : HEAD
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 1774bd5..460c6a5 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -7,10 +7,10 @@
zip_add.c zip_replace.c zip_add_zip.c zip_replace_zip.c \
zip_add_data.c zip_replace_data.c zip_add_file.c zip_replace_file.c \
zip_delete.c zip_unchange.c zip_rename.c \
- zf_new_free.c zip_new_entry.c zip_free_entry.c \
+ zip_new.c zip_free.c zip_new_entry.c zip_free_entry.c \
zip_new_meta.c zip_free_meta.c zip_merge_meta.c zip_unchange_data.c
BUILT_SOURCES=zip_err_str.c
zip_err_str.c: zip.h make_zip_err_str.sh
- $(srcdir)/make_zip_err_str.sh $(srcdir)/zip.h zip_err_str.c
\ No newline at end of file
+ $(srcdir)/make_zip_err_str.sh $(srcdir)/zip.h zip_err_str.c
diff --git a/lib/zip_free.c b/lib/zip_free.c
new file mode 100644
index 0000000..3c89660
--- /dev/null
+++ b/lib/zip_free.c
@@ -0,0 +1,50 @@
+#include <stdlib.h>
+#include "zip.h"
+#include "zipint.h"
+
+
+
+/* _zip_free:
+ frees the space allocated to a zipfile struct, and closes the
+ corresponding file. Returns 0 if successful, the error returned
+ by fclose if not. */
+
+int
+_zip_free(struct zip *zf)
+{
+ int i, ret;
+
+ if (zf == NULL)
+ return 0;
+
+ if (zf->zn)
+ free(zf->zn);
+
+ if (zf->zp)
+ ret = fclose(zf->zp);
+
+ if (zf->com)
+ free(zf->com);
+
+ if (zf->entry) {
+ for (i=0; i<zf->nentry; i++) {
+ _zip_free_entry(zf->entry+i);
+ }
+ free (zf->entry);
+ }
+
+ for (i=0; i<zf->nfile; i++) {
+ zf->file[i]->flags = ZERR_ZIPCLOSED;
+ zf->file[i]->zf = NULL;
+ zf->file[i]->name = NULL;
+ }
+
+ free(zf->file);
+
+ free(zf);
+
+ if (ret)
+ zip_err = ZERR_CLOSE;
+
+ return ret;
+}
diff --git a/lib/zip_new.c b/lib/zip_new.c
new file mode 100644
index 0000000..e4f2c95
--- /dev/null
+++ b/lib/zip_new.c
@@ -0,0 +1,32 @@
+#include <stdlib.h>
+#include "zip.h"
+#include "zipint.h"
+
+
+
+/* _zip_new:
+ creates a new zipfile struct, and sets the contents to zero; returns
+ the new struct. */
+
+struct zip *
+_zip_new(void)
+{
+ struct zip *zf;
+
+ zf = (struct zip *)malloc(sizeof(struct zip));
+ if (!zf) {
+ zip_err = ZERR_MEMORY;
+ return NULL;
+ }
+
+ zf->zn = NULL;
+ zf->zp = NULL;
+ zf->comlen = zf->changes = 0;
+ zf->nentry = zf->nentry_alloc = zf->cd_size = zf->cd_offset = 0;
+ zf->nfile = zf->nfile_alloc = 0;
+ zf->com = NULL;
+ zf->entry = NULL;
+ zf->file = NULL;
+
+ return zf;
+}