Commit 97bc304f authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

replaced designated initializer with manual initialization for struct...

replaced designated initializer with manual initialization for struct varDefZAxisSearchState since c++ does not support this feature, added explicit casts in various files
parent dd763dd0
......@@ -1097,7 +1097,7 @@ const char *modelInqNamePtr(int modelID);
void tableWriteC(const char *filename, int tableID);
void tableFWriteC(FILE *ptfp, int tableID);
void tableWrite(const char *filename, int tableID);
int tableRead(const char *tablefile);
int tableRead(char *tablefile);
int tableDef(int modelID, int tablenum, const char *tablename);
const char *tableInqNamePtr(int tableID);
......
......@@ -56,7 +56,7 @@ static int activeNamespace = 0;
CDI_NETCDF_SWITCHES \
}
#if defined (SX)
#if defined (SX) || defined (__cplusplus)
static const union namespaceSwitchValue
defaultSwitches_[NUM_NAMESPACE_SWITCH] = defaultSwitches;
#endif
......@@ -184,15 +184,15 @@ namespaceNew()
xassert(newNamespaceID >= 0 && newNamespaceID < NUM_NAMESPACES);
++nNamespaces;
namespaces[newNamespaceID].resStage = STAGE_DEFINITION;
#if defined (SX)
#if defined (SX) || defined (__cplusplus)
memcpy(namespaces[newNamespaceID].switches,
defaultSwitches_,
sizeof (namespaces[newNamespaceID].switches));
#else
memcpy(namespaces[newNamespaceID].switches,
(union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
sizeof (namespaces[newNamespaceID].switches));
#endif
#else
memcpy(namespaces[newNamespaceID].switches,
(union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
sizeof (namespaces[newNamespaceID].switches));
#endif
reshListCreate(newNamespaceID);
NAMESPACE_UNLOCK();
return newNamespaceID;
......
......@@ -421,7 +421,7 @@ int extScanTimestep2(stream_t *streamptr)
cdi_create_records(streamptr, tsID);
nrecords = streamptr->tsteps[0].nallrecs;
streamptr->tsteps[1].recIDs = xmalloc((size_t)nrecords * sizeof (int));
streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
streamptr->tsteps[1].nrecs = 0;
for ( recID = 0; recID < nrecords; recID++ )
streamptr->tsteps[1].recIDs[recID] = -1;
......
......@@ -21,7 +21,7 @@ void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
if (fileSetPos(fileID1, recpos, SEEK_SET) != 0)
Error("Cannot seek input file for %s record copy!", container_name);
char *buffer = xmalloc(recsize);
char *buffer = (char *)xmalloc(recsize);
if (fileRead(fileID1, buffer, recsize) != recsize)
Error("Failed to read record from %s file for copying!", container_name);
......
......@@ -715,7 +715,7 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
/* round up recsize to next multiple of 8 */
size_t gribbuffersize = ((recsize + 7U) & ~7U);
unsigned char *gribbuffer = xmalloc(gribbuffersize);
unsigned char *gribbuffer = (unsigned char *)xmalloc(gribbuffersize);
if (fileRead(fileID1, gribbuffer, recsize) != recsize)
Error("Could not read GRIB record for copying!");
......
......@@ -411,7 +411,7 @@ void subtypeDestroyPtr(void *ptr)
/* Non-static wrapper function for "subtypeCompareP". */
int subtypeComparePtr(int s1_ID, subtype_t *s2)
{
subtype_t *subtype_ptr = reshGetVal(s1_ID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(s1_ID, &subtypeOps);
if (subtype_ptr == NULL) Error("Internal error");
return subtypeCompareP(subtype_ptr,s2);
}
......@@ -420,7 +420,7 @@ int subtypeComparePtr(int s1_ID, subtype_t *s2)
/* Print-out subtype data structure together with its attributes.
Pointer version of this method. */
static void subtypePrintP(void * subtype_ptr, FILE * fp)
{ subtypePrintKernel(subtype_ptr, fp); }
{ subtypePrintKernel((subtype_t *)subtype_ptr, fp); }
......@@ -500,7 +500,7 @@ void subtypeDefGlobalDataP(subtype_t *subtype_ptr, int key, int val)
overwritten. */
void subtypeDefGlobalData(int subtypeID, int key, int val)
{
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
subtypeDefGlobalDataP(subtype_ptr, key, val);
}
......@@ -523,7 +523,7 @@ int subtypeGetGlobalDataP(subtype_t *subtype_ptr, int key)
If the attribute has not been defined, then return -1. */
int subtypeGetGlobalData(int subtypeID, int key)
{
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
return subtypeGetGlobalDataP(subtype_ptr, key);
}
......@@ -691,7 +691,7 @@ int subtypeCreate(int subtype)
/* Print-out subtype data structure together with its attributes. */
void subtypePrint(int subtypeID)
{
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
subtypePrintKernel(subtype_ptr, stdout);
}
......@@ -699,8 +699,8 @@ void subtypePrint(int subtypeID)
/* Compares two subtype data structures. */
int subtypeCompare(int subtypeID1, int subtypeID2)
{
subtype_t *subtype_ptr1 = reshGetVal(subtypeID1, &subtypeOps);
subtype_t *subtype_ptr2 = reshGetVal(subtypeID2, &subtypeOps);
subtype_t *subtype_ptr1 = (subtype_t *)reshGetVal(subtypeID1, &subtypeOps);
subtype_t *subtype_ptr2 = (subtype_t *)reshGetVal(subtypeID2, &subtypeOps);
return subtypeCompareP(subtype_ptr1,subtype_ptr2);
}
......@@ -714,7 +714,7 @@ int subtypeInqSize(int subtypeID)
}
else
{
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
return subtype_ptr->nentries;
}
}
......@@ -724,7 +724,7 @@ int subtypeInqSize(int subtypeID)
int subtypeInqActiveIndex(int subtypeID)
{
if (subtypeID == CDI_UNDEFID) return 0;
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
return subtype_ptr->active_subtype_index;
}
......@@ -732,7 +732,7 @@ int subtypeInqActiveIndex(int subtypeID)
/* Set the currently active index of a subtype (e.g. current tile index). */
void subtypeDefActiveIndex(int subtypeID, int index)
{
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
subtype_ptr->active_subtype_index = index;
}
......@@ -741,7 +741,7 @@ void subtypeDefActiveIndex(int subtypeID, int index)
criterion. */
int subtypeInqSubEntry(int subtypeID, subtype_query_t criterion)
{
subtype_t *subtype_ptr = reshGetVal(subtypeID, &subtypeOps);
subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
struct subtype_entry_t *entry = subtype_ptr->entries;
/* loop over all entries of this subtype */
while (entry != NULL) {
......
......@@ -319,7 +319,7 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
return (0);
}
int tableRead(const char *tablefile)
int tableRead(char *tablefile)
{
char line[1024], *pline;
int lnr = 0;
......
......@@ -70,7 +70,7 @@ static char *
new_refcount_string(size_t len)
{
struct refcount_string *container
= xmalloc(sizeof (*container) + len + 1);
= (struct refcount_string *)xmalloc(sizeof (*container) + len + 1);
container->ref_count = 1;
return container->string;
}
......
......@@ -102,7 +102,7 @@ char* cdiEscapeSpaces(const char* string)
for(; string[length]; ++length)
escapeCount += string[length] == ' ' || string[length] == '\\';
char* result = malloc(length + escapeCount + 1);
char* result = (char *)malloc(length + escapeCount + 1);
if(!result) return NULL;
//Do the escaping.
......@@ -132,7 +132,7 @@ char* cdiUnescapeSpaces(const char* string, const char** outStringEnd)
length++;
}
char* result = malloc(length + 1);
char* result = (char *)malloc(length + 1);
if(!result) return NULL;
//Do the unescaping.
......
......@@ -993,7 +993,7 @@ struct varDefZAxisSearchState
static enum cdiApplyRet
varDefZAxisSearch(int id, void *res, void *data)
{
struct varDefZAxisSearchState *state = data;
struct varDefZAxisSearchState *state = (struct varDefZAxisSearchState *)data;
(void)res;
if (zaxisCompare(id, state->zaxistype, state->nlevels, state->lbounds,
state->levels, state->longname, state->units, state->ltype)
......@@ -1040,15 +1040,25 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
if ( ! zaxisdefined )
{
struct varDefZAxisSearchState query = {
.zaxistype = zaxistype,
.nlevels = nlevels,
.levels = levels,
.lbounds = lbounds,
.longname = longname,
.units = units,
.ltype = ltype1,
};
struct varDefZAxisSearchState query;
query.zaxistype = zaxistype;
query.nlevels = nlevels;
query.levels = levels;
query.lbounds = lbounds;
query.longname = longname;
query.units = units;
query.ltype = ltype1;
// = {
// .zaxistype = zaxistype,
// .nlevels = nlevels,
// .levels = levels,
// .lbounds = lbounds,
// .longname = longname,
// .units = units,
// .ltype = ltype1,
// };
if ((zaxisglobdefined
= (cdiResHFilterApply(&zaxisOps, varDefZAxisSearch, &query)
== CDI_APPLY_STOP)))
......
......@@ -352,7 +352,7 @@ void vlistCopy(int vlistID2, int vlistID1)
//vlistptr2->varsAllocated = nvars;
size_t n = (size_t)vlistptr2->varsAllocated;
vars2 = xrealloc(vars2, n*sizeof(var_t));
vars2 = (var_t *)xrealloc(vars2, n*sizeof(var_t));
memcpy(vars2, vars1, n*sizeof(var_t));
vlistptr2->vars = vars2;
......@@ -366,7 +366,7 @@ void vlistCopy(int vlistID2, int vlistID1)
if ( vars1[varID].levinfo )
{
n = (size_t)zaxisInqSize(vars1[varID].zaxisID);
vars2[varID].levinfo = xmalloc(n*sizeof(levinfo_t));
vars2[varID].levinfo = (levinfo_t *)xmalloc(n*sizeof(levinfo_t));
memcpy(vars2[varID].levinfo, vars1[varID].levinfo, n*sizeof(levinfo_t));
}
}
......@@ -683,7 +683,7 @@ void vlistCat(int vlistID2, int vlistID1)
if ( nvars > vlistptr2->varsAllocated )
{
vlistptr2->varsAllocated = nvars;
vars2 = xrealloc(vars2, (size_t)nvars*sizeof(var_t));
vars2 = (var_t *)xrealloc(vars2, (size_t)nvars*sizeof(var_t));
vlistptr2->vars = vars2;
}
memcpy(vars2+nvars2, vars1, (size_t)nvars1 * sizeof(var_t));
......@@ -1481,7 +1481,7 @@ void vlistPackP ( void * vlistptr, void * buf, int size, int *position,
vlistAttsPack(p, CDI_GLOBAL, buf, size, position, context);
for ( varID = 0; varID < p->nvars; varID++ )
{
vlistVarPack(p, varID, buf, size, position, context);
vlistVarPack(p, varID, (char *)buf, size, position, context);
}
}
......
......@@ -564,13 +564,13 @@ char* vlistCopyVarName(int vlistId, int varId)
result = strdup(name);
{
//No luck, fall back to outputting a name of the format "var<num>".
result = xmalloc(3 + 3 * sizeof (int) * CHAR_BIT / 8 + 2);
result = (char *)xmalloc(3 + 3 * sizeof (int) * CHAR_BIT / 8 + 2);
sprintf(result, "var%d", number);
}
}
else
{
result = xmalloc(5 + 2 + 3 * (3 * sizeof (int) * CHAR_BIT + 1) + 1);
result = (char *)xmalloc(5 + 2 + 3 * (3 * sizeof (int) * CHAR_BIT + 1) + 1);
sprintf(result, "param%d.%d.%d", number, category, discipline);
}
//Finally, we fall back to outputting a name of the format "param<num>.<cat>.<dis>".
......
......@@ -310,7 +310,7 @@ static void zaxisDestroyKernel( zaxis_t * zaxisptr )
*/
void zaxisDestroy(int zaxisID)
{
zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
zaxis_t *zaxisptr = (zaxis_t *)reshGetVal(zaxisID, &zaxisOps);
zaxisDestroyKernel ( zaxisptr );
}
......
......@@ -7,7 +7,7 @@ int zaxisSize(void);
unsigned cdiZaxisCount(void);
void cdiZaxisGetIndexList(unsigned numIDs, int IDs[numIDs]);
void cdiZaxisGetIndexList(unsigned numIDs, int *IDs);
void
zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
......
Supports Markdown
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