diff contrib/python-zstandard/c-ext/compressiondict.c @ 30822:b54a2984cdd4

zstd: vendor python-zstandard 0.6.0 Commit 63c68d6f5fc8de4afd9bde81b13b537beb4e47e8 from https://github.com/indygreg/python-zstandard is imported without modifications (other than removing unwanted files). This includes minor performance and feature improvements. It also changes the vendored zstd library from 1.1.1 to 1.1.2. # no-check-commit
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 14 Jan 2017 19:41:43 -0800
parents b86a448a2965
children c32454d69b85
line wrap: on
line diff
--- a/contrib/python-zstandard/c-ext/compressiondict.c	Sat Jan 14 20:05:15 2017 +0530
+++ b/contrib/python-zstandard/c-ext/compressiondict.c	Sat Jan 14 19:41:43 2017 -0800
@@ -65,14 +65,14 @@
 
 	/* Now that we know the total size of the raw simples, we can allocate
 	a buffer for the raw data */
-	sampleBuffer = malloc(samplesSize);
+	sampleBuffer = PyMem_Malloc(samplesSize);
 	if (!sampleBuffer) {
 		PyErr_NoMemory();
 		return NULL;
 	}
-	sampleSizes = malloc(samplesLen * sizeof(size_t));
+	sampleSizes = PyMem_Malloc(samplesLen * sizeof(size_t));
 	if (!sampleSizes) {
-		free(sampleBuffer);
+		PyMem_Free(sampleBuffer);
 		PyErr_NoMemory();
 		return NULL;
 	}
@@ -87,10 +87,10 @@
 		sampleOffset = (char*)sampleOffset + sampleSize;
 	}
 
-	dict = malloc(capacity);
+	dict = PyMem_Malloc(capacity);
 	if (!dict) {
-		free(sampleSizes);
-		free(sampleBuffer);
+		PyMem_Free(sampleSizes);
+		PyMem_Free(sampleBuffer);
 		PyErr_NoMemory();
 		return NULL;
 	}
@@ -100,9 +100,9 @@
 		zparams);
 	if (ZDICT_isError(zresult)) {
 		PyErr_Format(ZstdError, "Cannot train dict: %s", ZDICT_getErrorName(zresult));
-		free(dict);
-		free(sampleSizes);
-		free(sampleBuffer);
+		PyMem_Free(dict);
+		PyMem_Free(sampleSizes);
+		PyMem_Free(sampleBuffer);
 		return NULL;
 	}
 
@@ -140,7 +140,7 @@
 		return -1;
 	}
 
-	self->dictData = malloc(sourceSize);
+	self->dictData = PyMem_Malloc(sourceSize);
 	if (!self->dictData) {
 		PyErr_NoMemory();
 		return -1;
@@ -154,7 +154,7 @@
 
 static void ZstdCompressionDict_dealloc(ZstdCompressionDict* self) {
 	if (self->dictData) {
-		free(self->dictData);
+		PyMem_Free(self->dictData);
 		self->dictData = NULL;
 	}