corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [1/2] incubator-corinthia git commit: added complex releasememory
Date Sat, 01 Aug 2015 11:02:53 GMT
Repository: incubator-corinthia
Updated Branches:
  refs/heads/newZipExperiment 0a2dd7329 -> bc2f161ad


added complex releasememory


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/28662383
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/28662383
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/28662383

Branch: refs/heads/newZipExperiment
Commit: 2866238306d08ee507df29a83eabc3898f01c367
Parents: 0a2dd73
Author: jani <jani@apache.org>
Authored: Sat Aug 1 09:56:40 2015 +0200
Committer: jani <jani@apache.org>
Committed: Sat Aug 1 09:56:40 2015 +0200

----------------------------------------------------------------------
 DocFormats/platform/src/Wrapper_zip.c | 42 ++++++++++++++----------------
 1 file changed, 20 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/28662383/DocFormats/platform/src/Wrapper_zip.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/src/Wrapper_zip.c b/DocFormats/platform/src/Wrapper_zip.c
index 09cfb89..89d3b49 100644
--- a/DocFormats/platform/src/Wrapper_zip.c
+++ b/DocFormats/platform/src/Wrapper_zip.c
@@ -143,13 +143,29 @@ static int readDirectory(FILE *zipFile, DFextZipHandleP zipHandle)
 		if (fseek(zipFile, recDir->extraFieldLength, SEEK_CUR)
 			|| fseek(zipFile, recDir->fileCommentLength, SEEK_CUR))
 			return -1;
-	}
+	};
 
 	return 0;
 }
 
 
 
+static void releaseMemory(DFextZipHandleP zipHandle) {
+	if (zipHandle) {
+		if (zipHandle->zipFileEntries) {
+			for (int i = 0; i < zipHandle->zipFileCount; i++) {
+				DFextZipDirEntry *zipDirEntry = zipHandle->zipFileEntries + (i * sizeof(zipDirEntry));
+				if (zipDirEntry->fileName)
+					free(zipDirEntry->fileName);
+			}
+			free(zipHandle->zipFileEntries);
+		}
+		free(zipHandle);
+	}
+}
+
+
+
 DFextZipHandleP DFextZipOpen(const char *zipFilename) {
     DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
 
@@ -160,31 +176,12 @@ DFextZipHandleP DFextZipOpen(const char *zipFilename) {
 		return zipHandle;
 
 	// release memory
-    free(zipHandle);
+    releaseMemory(zipHandle);
     return NULL;
 }
 
 
 
-DFextZipHandleP OLD_DFextZipOpen(const char *zipFilename) {
-	DFextZipHandleP zipHandle = xmalloc(sizeof(DFextZipHandle));
-
-#if 0
-	// no more memory
-	if (!zipHandle)
-		return NULL;
-
-	// Open file
-	zipHandle->zipFirst = 1;
-	zipHandle->handle = unzOpen(zipFilename);
-
-	if (zipHandle->handle)
-		return zipHandle;
-
-	free(zipHandle);
-#endif
-	return NULL;
-}
 
 
 
@@ -224,7 +221,8 @@ int DFextZipClose(DFextZipHandleP zipHandle)
 
     free(zipHandle);
 #endif
-    return rc ? 1 : -1;
+	releaseMemory(zipHandle);
+	return rc ? 1 : -1;
 }
 
 


Mime
View raw message