Commit 693f0f3d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added cdiInitKeys().

parent f927d7da
......@@ -574,6 +574,14 @@ const char *cdiInqVarKeyStringPtr(cdi_keys_t *keysp, int key)
return NULL;
}
void cdiInitKeys(cdi_keys_t *keysp)
{
keysp->nalloc = MAX_KEYS;
keysp->nelems = 0;
for ( int i = 0; i < MAX_KEYS; ++i )
keysp->value[i].length = 0;
}
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -56,6 +56,8 @@ void cdiDeleteVarKeys(cdi_keys_t *keysp);
void cdiDeleteKeys(int cdiID, int varID);
void cdiPrintKeys(int cdiID, int varID);
void cdiInitKeys(cdi_keys_t *keysp);
#endif
/*
......
......@@ -127,10 +127,7 @@ void grid_axis_init(struct gridaxis_t *axisptr)
axisptr->cvals = NULL;
#endif
axisptr->stdname = NULL;
axisptr->keys.nalloc = MAX_KEYS;
axisptr->keys.nelems = 0;
for ( int i = 0; i < MAX_KEYS; ++i )
axisptr->keys.value[i].length = 0;
cdiInitKeys(&axisptr->keys);
}
void grid_init(grid_t *gridptr)
......@@ -168,10 +165,7 @@ void grid_init(grid_t *gridptr)
gridptr->hasdims = true;
gridptr->name = NULL;
gridptr->vtable = &cdiGridVtable;
gridptr->keys.nalloc = MAX_KEYS;
gridptr->keys.nelems = 0;
for ( int i = 0; i < MAX_KEYS; ++i )
gridptr->keys.value[i].length = 0;
cdiInitKeys(&gridptr->keys);
gridptr->atts.nalloc = MAX_ATTRIBUTES;
gridptr->atts.nelems = 0;
gridptr->iScansNegatively = 0;
......@@ -248,11 +242,11 @@ void grid_copy_base_scalar_fields(grid_t *gridptrOrig, grid_t *gridptrDup)
{
memcpy(gridptrDup, gridptrOrig, sizeof(grid_t));
gridptrDup->self = CDI_UNDEFID;
gridptrDup->keys.nelems = 0;
cdiInitKeys(&gridptrDup->keys);
cdiCopyVarKeys(&gridptrOrig->keys, &gridptrDup->keys);
gridptrDup->x.keys.nelems = 0;
cdiInitKeys(&gridptrDup->x.keys);
cdiCopyVarKeys(&gridptrOrig->x.keys, &gridptrDup->x.keys);
gridptrDup->y.keys.nelems = 0;
cdiInitKeys(&gridptrDup->y.keys);
cdiCopyVarKeys(&gridptrOrig->y.keys, &gridptrDup->y.keys);
if ( gridptrOrig->reference ) gridptrDup->reference = strdupx(gridptrOrig->reference);
}
......
......@@ -113,8 +113,7 @@ void paramInitEntry(unsigned varID, int param)
vartable[varID].instID = CDI_UNDEFID;
vartable[varID].modelID = CDI_UNDEFID;
vartable[varID].tableID = CDI_UNDEFID;
vartable[varID].keys.nalloc = MAX_KEYS;
vartable[varID].keys.nelems = 0;
cdiInitKeys(&vartable[varID].keys);
vartable[varID].comptype = CDI_COMPRESS_NONE;
vartable[varID].complevel = 1;
vartable[varID].lmissval = false;
......@@ -515,7 +514,7 @@ int cmpLevelTableInv(const void* s1, const void* s2)
void varCopyKeys(int vlistID, int varID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
vlistptr->vars[varID].keys.nelems = 0;
cdiInitKeys(&vlistptr->vars[varID].keys);
cdiCopyVarKeys(&vartable[varID].keys, &vlistptr->vars[varID].keys);
}
......
......@@ -133,10 +133,7 @@ void zaxis_init(zaxis_t *zaxisptr)
zaxisptr->nhlev = 0;
memset(zaxisptr->uuid, 0, CDI_UUID_SIZE);
zaxisptr->keys.nalloc = MAX_KEYS;
zaxisptr->keys.nelems = 0;
for ( int i = 0; i < MAX_KEYS; ++i )
zaxisptr->keys.value[i].length = 0;
cdiInitKeys(&zaxisptr->keys);
zaxisptr->atts.nalloc = MAX_ATTRIBUTES;
zaxisptr->atts.nelems = 0;
}
......@@ -175,7 +172,7 @@ void zaxis_copy(zaxis_t *zaxisptr2, zaxis_t *zaxisptr1)
const int zaxisID2 = zaxisptr2->self;
memcpy(zaxisptr2, zaxisptr1, sizeof(zaxis_t));
zaxisptr2->self = zaxisID2;
zaxisptr2->keys.nelems = 0;
cdiInitKeys(&zaxisptr2->keys);
cdiCopyVarKeys(&zaxisptr1->keys, &zaxisptr2->keys);
}
......@@ -820,6 +817,7 @@ int zaxisInqLevels(int zaxisID, double *levels)
return size;
}
int zaxisInqCLen(int zaxisID)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
......@@ -833,6 +831,7 @@ int zaxisInqCLen(int zaxisID)
return clen;
}
int zaxisInqCVals(int zaxisID, char ***clevels)
{
zaxis_t *zaxisptr = zaxis_to_pointer(zaxisID);
......
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