From b3f532145a0d9455ea8a374d3386703f3247aab4 Mon Sep 17 00:00:00 2001 From: Thomas Jahns <jahns@dkrz.de> Date: Thu, 17 Mar 2022 00:34:22 +0100 Subject: [PATCH] Fix missing wrapper conversion. --- src/grb_write.c | 2 +- src/pio_dbuffer.c | 3 +-- src/stream_gribapi.c | 2 +- tests/simple_model_helper.c | 2 +- tests/stream_cksum.c | 6 +++--- tests/test_cdf_read.c | 7 ++++--- tests/test_grib.c | 4 ++-- tests/test_resource_copy.c | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/grb_write.c b/src/grb_write.c index 02ea1f155..ec1e4e96b 100644 --- a/src/grb_write.c +++ b/src/grb_write.c @@ -168,7 +168,7 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1) gridsize = vlistGridsizeMax(vlistID); if ( vlistNumber(vlistID) != CDI_REAL ) gridsize *= 2; - double * data = (double *) malloc(gridsize*sizeof(double)); + double * data = (double *) Malloc(gridsize*sizeof(double)); //int missval = vlistInqVarMissval(vlistID, varID); //streamptr->numvals += gridsize; diff --git a/src/pio_dbuffer.c b/src/pio_dbuffer.c index 478832258..65cc0655b 100644 --- a/src/pio_dbuffer.c +++ b/src/pio_dbuffer.c @@ -54,8 +54,7 @@ cdiPioDbufferInit(struct dBuffer *db, size_t bufSize) db->buffer = (unsigned char *)buf; #else db->size = bufSize; - db->buffer = (unsigned char *)malloc(bufSize); - assert(db->buffer); + db->buffer = (unsigned char *)Malloc(bufSize); #endif } diff --git a/src/stream_gribapi.c b/src/stream_gribapi.c index cdfdd05ba..af1e36f18 100644 --- a/src/stream_gribapi.c +++ b/src/stream_gribapi.c @@ -2783,7 +2783,7 @@ convertDataScanningMode(int scanModeIN, int scanModeOUT, double *data, } } double *dataCopy = NULL; - dataCopy = (double *) malloc(gridsize*sizeof(double)); + dataCopy = (double *) Malloc(gridsize*sizeof(double)); memcpy((void*)dataCopy,(void*) data, gridsize*sizeof(double)); diff --git a/tests/simple_model_helper.c b/tests/simple_model_helper.c index 173e58850..1c8d570a5 100644 --- a/tests/simple_model_helper.c +++ b/tests/simple_model_helper.c @@ -275,7 +275,7 @@ int PPM_prime_factorization_32(uint32_t n, uint32_t **factors) { if (n <= 1) return 0; - uint32_t * restrict pfactors = realloc(*factors, 32 * sizeof (pfactors[0])); + uint32_t * restrict pfactors = Realloc(*factors, 32 * sizeof (pfactors[0])); size_t numFactors = 0; uint32_t unfactored = n; while (!(unfactored & 1)) diff --git a/tests/stream_cksum.c b/tests/stream_cksum.c index ccfba17e1..8c273d9c6 100644 --- a/tests/stream_cksum.c +++ b/tests/stream_cksum.c @@ -58,7 +58,7 @@ cksum_stream(const char *fname, size_t *table_len) break; } checksum_state = (uint32_t *) Calloc((size_t)nvars, sizeof (checksum_state[0])); - varDesc = (struct var_desc_t *)malloc((size_t)nvars * sizeof (varDesc[0])); + varDesc = (struct var_desc_t *)Malloc((size_t)nvars * sizeof (varDesc[0])); for (int varIdx = 0; varIdx < nvars; ++varIdx) { @@ -143,7 +143,7 @@ cksum_stream(const char *fname, size_t *table_len) if (var_size_max_chars < varDesc[varIdx].chars) var_size_max_chars = varDesc[varIdx].chars; } - buf = (double*)malloc(var_size_max_chars); + buf = (double*)Malloc(var_size_max_chars); if (nvars == -1) break; @@ -182,7 +182,7 @@ cksum_stream(const char *fname, size_t *table_len) ++tsID; } - file_vars = (struct cksum_table *)malloc((size_t)nvars + file_vars = (struct cksum_table *)Malloc((size_t)nvars * sizeof (file_vars[0])); for (int varIdx = 0; varIdx < nvars; ++varIdx) { diff --git a/tests/test_cdf_read.c b/tests/test_cdf_read.c index c7c58bf88..e1029a6ee 100644 --- a/tests/test_cdf_read.c +++ b/tests/test_cdf_read.c @@ -7,6 +7,7 @@ #include <stdio.h> #include "cdi.h" +#include "dmemory.h" static void printAtts(int vlistID); @@ -44,7 +45,7 @@ int main(int argc, const char **argv) int nmiss; if (memSize > bufSize) { - double *temp = (double *)realloc(buf, memSize); + double *temp = (double *)Realloc(buf, memSize); if (!temp) { perror("read buffer reallocation failed"); @@ -71,7 +72,7 @@ printAtts(int vlistID) varDescPrefix[] = "variable "; size_t digitsPerInt = 9; size_t bufSize = digitsPerInt + sizeof (varDescPrefix); - void *restrict buf = malloc(bufSize); + void *restrict buf = Malloc(bufSize); if (!buf) { perror("attribute buffer resize failed"); @@ -117,7 +118,7 @@ printAtts(int vlistID) size_t attSize = elemSize * ((size_t)attLen + 1); if (attSize > bufSize) { - if (!(buf = realloc(buf, attSize))) + if (!(buf = Realloc(buf, attSize))) { perror("attribute buffer resize failed"); exit(EXIT_FAILURE); diff --git a/tests/test_grib.c b/tests/test_grib.c index 9c94e1380..273689c30 100644 --- a/tests/test_grib.c +++ b/tests/test_grib.c @@ -30,7 +30,7 @@ int main() size_t datasize = (size_t)nlon * (size_t)nlat; - data = (double *)malloc(datasize * sizeof (double)); + data = (double *)Malloc(datasize * sizeof (double)); memset(data, 0, datasize * sizeof (double)); gridID = gridCreate(GRID_GAUSSIAN, (int)datasize); @@ -87,7 +87,7 @@ int main() if ( gridsize*varNlevel > datasize ) datasize = gridsize*varNlevel; } - data = (double *)realloc(data, datasize*sizeof(double)); + data = (double *)Realloc(data, datasize*sizeof(double)); memset(data, 0, datasize*sizeof(double)); taxisID = vlistInqTaxis(vlistID); diff --git a/tests/test_resource_copy.c b/tests/test_resource_copy.c index 106707bb5..e4cb3c826 100644 --- a/tests/test_resource_copy.c +++ b/tests/test_resource_copy.c @@ -215,7 +215,7 @@ static int modelRun(MPI_Comm comm) } reshPackBufferCreate ( &sendBuffer, &bufferSize, &comm ); - recvBuffer = (char *)malloc((size_t)bufferSize); + recvBuffer = (char *)Malloc((size_t)bufferSize); #ifdef USE_MPI xmpi(MPI_Sendrecv(sendBuffer, bufferSize, MPI_PACKED, 0, 0, recvBuffer, bufferSize, MPI_PACKED, 0, 0, -- GitLab