Commit 41ab38ce authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

replaced all xrealloc with realloc in src

parent ed06b81f
......@@ -34,7 +34,7 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
{
char* result = (char *)malloc(length);
if(!grib_get_string(gribHandle, key, result, &length))
result = (char *)xrealloc(result, length);
result = (char *)realloc(result, length);
else
{
......@@ -55,13 +55,13 @@ char* gribCopyString(grib_handle* gribHandle, const char* key)
if (length <= 1024UL * 1024UL)
{
length *= 2;
result = xrealloc(result, length);
result = realloc(result, length);
}
else
break;
}
if (!rc)
result = xrealloc(result, length);
result = realloc(result, length);
else
{
free(result);
......
......@@ -1404,7 +1404,7 @@ void gridDefXvals(int gridID, const double *xvals)
if (gridptr->xvals && CDI_Debug)
Warning("values already defined!");
gridptr->xvals = (double *)xrealloc(gridptr->xvals,
gridptr->xvals = (double *)realloc(gridptr->xvals,
(size_t)size * sizeof(double));
memcpy(gridptr->xvals, xvals, (size_t)size * sizeof (double));
reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
......@@ -1479,7 +1479,7 @@ void gridDefYvals(int gridID, const double *yvals)
if (gridptr->yvals && CDI_Debug)
Warning("Values already defined!");
gridptr->yvals = (double *)xrealloc(gridptr->yvals, (size_t)size * sizeof (double));
gridptr->yvals = (double *)realloc(gridptr->yvals, (size_t)size * sizeof (double));
memcpy(gridptr->yvals, yvals, (size_t)size * sizeof (double));
reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
}
......@@ -2763,19 +2763,19 @@ void gridCompress(int gridID)
gridptr->ysize = (int)gridsize;
if ( gridptr->xvals )
gridptr->xvals = (double *)xrealloc(gridptr->xvals, gridsize*sizeof(double));
gridptr->xvals = (double *)realloc(gridptr->xvals, gridsize*sizeof(double));
if ( gridptr->yvals )
gridptr->yvals = (double *)xrealloc(gridptr->yvals, gridsize*sizeof(double));
gridptr->yvals = (double *)realloc(gridptr->yvals, gridsize*sizeof(double));
if ( gridptr->area )
gridptr->area = (double *)xrealloc(gridptr->area, gridsize*sizeof(double));
gridptr->area = (double *)realloc(gridptr->area, gridsize*sizeof(double));
if ( gridptr->xbounds )
gridptr->xbounds = (double *)xrealloc(gridptr->xbounds, nv*gridsize*sizeof(double));
gridptr->xbounds = (double *)realloc(gridptr->xbounds, nv*gridsize*sizeof(double));
if ( gridptr->ybounds )
gridptr->ybounds = (double *)xrealloc(gridptr->ybounds, nv*gridsize*sizeof(double));
gridptr->ybounds = (double *)realloc(gridptr->ybounds, nv*gridsize*sizeof(double));
free(gridptr->mask_gme);
gridptr->mask_gme = NULL;
......
......@@ -87,7 +87,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
{
openFileListSize *= 2;
if(openFileListSize < 16) openFileListSize = 16;
openFileList = (CdiInputFile **)xrealloc(openFileList, openFileListSize);
openFileList = (CdiInputFile **)realloc(openFileList, openFileListSize);
}
xassert(openFileCount < openFileListSize);
openFileList[openFileCount++] = result;
......
......@@ -196,7 +196,7 @@ static void cdiGribIterator_ensureBuffer(CdiGribIterator *me, size_t requiredSiz
{
me->bufferSize *= 2;
if(me->bufferSize < requiredSize) me->bufferSize = requiredSize;
me->gribBuffer = (unsigned char *)xrealloc(me->gribBuffer, me->bufferSize);
me->gribBuffer = (unsigned char *)realloc(me->gribBuffer, me->bufferSize);
}
}
......
......@@ -173,7 +173,7 @@ namespaceNew()
/* make room for additional namespace */
newNamespaceID = (int)namespacesSize;
namespaces
= (struct Namespace *)xrealloc(namespaces, ((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
= (struct Namespace *)realloc(namespaces, ((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
++namespacesSize;
}
else /* implicit: namespacesSize >= NUM_NAMESPACES */
......
......@@ -262,7 +262,7 @@ resizeVarGatherBuf(int vlistID, int varID, double **buf, int *bufSize)
{
int size = vlistInqVarSize(vlistID, varID);
if (size <= *bufSize) ; else
*buf = xrealloc(*buf, (size_t)(*bufSize = size) * sizeof (buf[0][0]));
*buf = realloc(*buf, (size_t)(*bufSize = size) * sizeof (buf[0][0]));
}
static void
......@@ -496,7 +496,7 @@ inventorizeStream(struct streamMapping *streamMap, int numStreamIDs,
int sizeStreamMap = *sizeStreamMap_;
if (numStreamIDs < sizeStreamMap) ; else
{
streamMap = xrealloc(streamMap,
streamMap = realloc(streamMap,
(size_t)(sizeStreamMap *= 2)
* sizeof (streamMap[0]));
*sizeStreamMap_ = sizeStreamMap;
......@@ -595,7 +595,7 @@ buildStreamMap(struct winHeaderEntry *winDict)
free(streamIDs);
}
/* sort written streams by streamID */
streamMap = xrealloc(streamMap, sizeof (streamMap[0]) * (size_t)numStreamIDs);
streamMap = realloc(streamMap, sizeof (streamMap[0]) * (size_t)numStreamIDs);
qsort(streamMap, (size_t)numStreamIDs, sizeof (streamMap[0]), smCmpStreamID);
return (struct streamMap){ .entries = streamMap, .numEntries = numStreamIDs };
}
......@@ -646,7 +646,7 @@ buildWrittenVars(struct streamMapping *mapping, int **varIsWritten_,
int nvars = mapping->numVars;
int *varMap = mapping->varMap;
int *varIsWritten = *varIsWritten_
= xrealloc(*varIsWritten_, sizeof (*varIsWritten) * (size_t)nvars);
= realloc(*varIsWritten_, sizeof (*varIsWritten) * (size_t)nvars);
for (int varID = 0; varID < nvars; ++varID)
varIsWritten[varID] = ((varMap[varID] != -1)
?myCollRank+1 : 0);
......@@ -793,7 +793,7 @@ static void readGetBuffers()
xt_idxlist_delete(preRedistChunk);
xt_idxlist_delete(preWriteChunk);
xt_xmap_delete(xmap);
writeBuf = (double*) xrealloc(writeBuf,
writeBuf = (double*) realloc(writeBuf,
sizeof (double)
* PPM_extents_size(3, varChunk));
xt_redist_s_exchange1(redist, data, writeBuf);
......
......@@ -152,7 +152,7 @@ reshListCreate(int namespaceID)
LIST_LOCK();
if (resHListSize <= namespaceID)
{
resHList = (struct resHList_t *)xrealloc(resHList, (size_t)(namespaceID + 1) * sizeof (resHList[0]));
resHList = (struct resHList_t *)realloc(resHList, (size_t)(namespaceID + 1) * sizeof (resHList[0]));
for (int i = resHListSize; i <= namespaceID; ++i)
reshListClearEntry(i);
resHListSize = namespaceID + 1;
......@@ -235,7 +235,7 @@ void listSizeExtend()
int oldSize = resHList[nsp].size;
size_t newListSize = (size_t)oldSize + MIN_LIST_SIZE;
resHList[nsp].resources = (listElem_t*) xrealloc(resHList[nsp].resources,
resHList[nsp].resources = (listElem_t*) realloc(resHList[nsp].resources,
newListSize * sizeof(listElem_t));
listElem_t *r = resHList[nsp].resources;
......
......@@ -67,7 +67,7 @@ void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
case STREAM:
if (sizeAssociations == numAssociations)
associations
= (struct streamAssoc *)xrealloc(associations,
= (struct streamAssoc *)realloc(associations,
sizeof (associations[0]) * (size_t)(sizeAssociations *= 2));
associations[numAssociations]
= streamUnpack(unpackBuffer, unpackBufferSize, &unpackBufferPos,
......
......@@ -574,7 +574,7 @@ resizeBuf(void **buf, size_t *bufSize, size_t reqSize)
{
if (reqSize > *bufSize)
{
*buf = xrealloc(*buf, reqSize);
*buf = realloc(*buf, reqSize);
*bufSize = reqSize;
}
return *buf;
......
......@@ -651,7 +651,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
if ( (size_t)recsize > buffersize )
{
buffersize = (size_t)recsize;
gribbuffer = (unsigned char *)xrealloc(gribbuffer, buffersize);
gribbuffer = (unsigned char *)realloc(gribbuffer, buffersize);
}
readsize = (size_t)recsize;
......@@ -885,7 +885,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
if ( (size_t)recsize > buffersize )
{
buffersize = (size_t)recsize;
gribbuffer = (unsigned char *)xrealloc(gribbuffer, buffersize);
gribbuffer = (unsigned char *)realloc(gribbuffer, buffersize);
}
readsize = (size_t)recsize;
......
......@@ -355,7 +355,7 @@ void extScanTimestep1(stream_t *streamptr)
{
streamptr->tsteps[0].recordSize = nrecords;
streamptr->tsteps[0].records =
(record_t *)xrealloc(streamptr->tsteps[0].records, (size_t)nrecords * sizeof (record_t));
(record_t *)realloc(streamptr->tsteps[0].records, (size_t)nrecords * sizeof (record_t));
}
streamptr->tsteps[0].recIDs = (int *)malloc((size_t)nrecords * sizeof (int));
......
......@@ -991,7 +991,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
{
streamptr->tsteps[0].recordSize = nrecords;
streamptr->tsteps[0].records =
(record_t *)xrealloc(streamptr->tsteps[0].records, (size_t)nrecords*sizeof(record_t));
(record_t *)realloc(streamptr->tsteps[0].records, (size_t)nrecords*sizeof(record_t));
}
streamptr->tsteps[0].recIDs = (int *)malloc((size_t)nrecords*sizeof(int));
......
......@@ -939,7 +939,7 @@ void iegScanTimestep1(stream_t *streamptr)
{
streamptr->tsteps[0].recordSize = nrecords;
streamptr->tsteps[0].records =
(record_t *)xrealloc(streamptr->tsteps[0].records,
(record_t *)realloc(streamptr->tsteps[0].records,
(size_t)nrecords * sizeof (record_t));
}
......
......@@ -70,7 +70,7 @@ int recordNewEntry(stream_t *streamptr, int tsID)
int i;
recordSize = 2*recordSize;
records = (record_t *)xrealloc(records,
records = (record_t *)realloc(records,
(size_t)recordSize * sizeof (record_t));
if ( records == NULL )
{
......
......@@ -349,7 +349,7 @@ void srvScanTimestep1(stream_t *streamptr)
{
streamptr->tsteps[0].recordSize = nrecords;
streamptr->tsteps[0].records =
(record_t *)xrealloc(streamptr->tsteps[0].records,
(record_t *)realloc(streamptr->tsteps[0].records,
(size_t)nrecords * sizeof(record_t));
}
......
......@@ -80,7 +80,7 @@ int streamvar_new_entry(stream_t *streamptr)
streamvarSize = 2*streamvarSize;
streamvar
= (svarinfo_t *)xrealloc(streamvar,
= (svarinfo_t *)realloc(streamvar,
(size_t)streamvarSize * sizeof (svarinfo_t));
if ( streamvar == NULL )
{
......
......@@ -41,7 +41,7 @@ int tstepsNewEntry(stream_t *streamptr)
{
if ( tstepsTableSize == 0 ) tstepsTableSize = 1;
tstepsTableSize = 2*tstepsTableSize;
tstepsTable = (tsteps_t *)xrealloc(tstepsTable,
tstepsTable = (tsteps_t *)realloc(tstepsTable,
(size_t)tstepsTableSize * sizeof (tsteps_t));
if ( tstepsTable == NULL )
{
......
......@@ -265,7 +265,7 @@ static int tileNewEntry(int varID)
tileID = vartable[varID].nsubtypes_alloc;
vartable[varID].nsubtypes_alloc *= 2;
vartable[varID].recordTable =
(subtypetable_t *)xrealloc(vartable[varID].recordTable,
(subtypetable_t *)realloc(vartable[varID].recordTable,
(size_t)vartable[varID].nsubtypes_alloc * sizeof (subtypetable_t));
if (vartable[varID].recordTable == NULL)
SysError("Reallocation of leveltable failed");
......@@ -326,7 +326,7 @@ static int levelNewEntry(unsigned varID, int level1, int level2, int tileID)
int i;
levelTableSize = 2*levelTableSize;
levelTable = (leveltable_t *)xrealloc(levelTable, (size_t)levelTableSize
levelTable = (leveltable_t *)realloc(levelTable, (size_t)levelTableSize
* sizeof (leveltable_t));
if( levelTable == NULL )
{
......@@ -395,7 +395,7 @@ paramNewEntry(int param)
{
varTablesize = 2 * varTablesize;
vartable = (vartable_t *)xrealloc(vartable, (size_t)varTablesize
vartable = (vartable_t *)realloc(vartable, (size_t)varTablesize
* sizeof (vartable_t));
if( vartable == NULL )
{
......
......@@ -352,7 +352,7 @@ void vlistCopy(int vlistID2, int vlistID1)
//vlistptr2->varsAllocated = nvars;
size_t n = (size_t)vlistptr2->varsAllocated;
vars2 = (var_t *)xrealloc(vars2, n*sizeof(var_t));
vars2 = (var_t *)realloc(vars2, n*sizeof(var_t));
memcpy(vars2, vars1, n*sizeof(var_t));
vlistptr2->vars = vars2;
......@@ -683,7 +683,7 @@ void vlistCat(int vlistID2, int vlistID1)
if ( nvars > vlistptr2->varsAllocated )
{
vlistptr2->varsAllocated = nvars;
vars2 = (var_t *)xrealloc(vars2, (size_t)nvars*sizeof(var_t));
vars2 = (var_t *)realloc(vars2, (size_t)nvars*sizeof(var_t));
vlistptr2->vars = vars2;
}
memcpy(vars2+nvars2, vars1, (size_t)nvars1 * sizeof(var_t));
......@@ -787,7 +787,7 @@ void vlistMerge(int vlistID2, int vlistID1)
*/
if ( vars1[varID].levinfo )
{
vars2[varID].levinfo = (levinfo_t*)xrealloc(vars2[varID].levinfo,
vars2[varID].levinfo = (levinfo_t*)realloc(vars2[varID].levinfo,
(size_t)nlevs * sizeof(levinfo_t));
memcpy(vars2[varID].levinfo+nlevs2, vars1[varID].levinfo,
......@@ -1351,7 +1351,7 @@ void vlistChangeZaxisIndex(int vlistID, int index, int zaxisID)
vlistptr->vars[varID].zaxisID = zaxisID;
if ( vlistptr->vars[varID].levinfo && nlevs != nlevsOld )
{
vlistptr->vars[varID].levinfo = (levinfo_t *)xrealloc(vlistptr->vars[varID].levinfo, (size_t)nlevs * sizeof (levinfo_t));
vlistptr->vars[varID].levinfo = (levinfo_t *)realloc(vlistptr->vars[varID].levinfo, (size_t)nlevs * sizeof (levinfo_t));
for ( int levID = 0; levID < nlevs; levID++ )
vlistptr->vars[varID].levinfo[levID] = DEFAULT_LEVINFO(levID);
......@@ -1386,7 +1386,7 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
if ( vlistptr->vars[varID].levinfo && nlevs2 != nlevs1 )
{
vlistptr->vars[varID].levinfo
= (levinfo_t *)xrealloc(vlistptr->vars[varID].levinfo,
= (levinfo_t *)realloc(vlistptr->vars[varID].levinfo,
(size_t)nlevs2 * sizeof(levinfo_t));
for ( int levID = 0; levID < nlevs2; levID++ )
......
......@@ -91,7 +91,7 @@ void fill_att(cdi_att_t *attp, int indtype, int exdtype, size_t nelems, size_t x
if ( xsz > 0 )
{
attp->xvalue = xrealloc(attp->xvalue, xsz);
attp->xvalue = realloc(attp->xvalue, xsz);
memcpy(attp->xvalue, xvalue, xsz);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment