Commit adf64576 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdi_att_compare: changed interface.

parent b64491fa
......@@ -454,19 +454,16 @@ int cdiAttTypeLookup(cdi_att_t *attp)
}
int cdi_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB, int attnum)
int cdi_att_compare(cdi_atts_t *attspa, cdi_atts_t *attspb, int attnum)
{
cdi_atts_t *attspa = get_attsp(a, varIDA),
*attspb = get_attsp(b, varIDB);
if (attspa == NULL && attspb == NULL) return 0;
xassert(attnum >= 0 && attnum < (int)attspa->nelems && attnum < (int)attspb->nelems);
cdi_att_t *attpa = attspa->value + attnum,
*attpb = attspb->value + attnum;
size_t len;
if ((len = attpa->namesz) != attpb->namesz) return 1;
int diff;
if ((diff = memcmp(attpa->name, attpb->name, len)))
return 1;
if (attpa->namesz != attpb->namesz) return 1;
if (memcmp(attpa->name, attpb->name, attpa->namesz)) return 1;
if (attpa->indtype != attpb->indtype
|| attpa->exdtype != attpb->exdtype
|| attpa->nelems != attpb->nelems)
......
......@@ -37,6 +37,8 @@ int cdiAttsGetSize(void *p, int varID, void *context);
void cdiAttsPack(void *p, int varID, void *buf, int size, int *position, void *context);
void cdiAttsUnpack(int cdiID, int varID, void *buf, int size, int *position, void *context);
int cdi_att_compare(cdi_atts_t *attspa, cdi_atts_t *attspb, int attnum);
#endif
/*
......
......@@ -51,24 +51,25 @@ vlist_compare(vlist_t *a, vlist_t *b)
| (a->nzaxis != b->nzaxis) | (a->instID != b->instID)
| (a->modelID != b->modelID) | (a->tableID != b->tableID)
| (a->ntsteps != b->ntsteps) | (a->atts.nelems != b->atts.nelems);
int nvars = a->nvars;
for (int varID = 0; varID < nvars; ++varID)
diff |= vlistVarCompare(a, varID, b, varID);
size_t natts = a->atts.nelems;
for (size_t attID = 0; attID < natts; ++attID)
diff |= cdi_att_compare(a, CDI_GLOBAL, b, CDI_GLOBAL, (int)attID);
diff |= cdi_att_compare(&a->atts, &a->atts, (int)attID);
return diff;
}
static void
vlistPrintKernel(vlist_t *vlistptr, FILE * fp );
static void
vlist_delete(vlist_t *vlistptr);
static void vlistPrintKernel(vlist_t *vlistptr, FILE *fp);
static void vlist_delete(vlist_t *vlistptr);
static int vlistGetSizeP ( void * vlistptr, void *context);
static void vlistPackP ( void * vlistptr, void * buff, int size,
int *position, void *context);
static int vlistTxCode ( void );
static int vlistGetSizeP (void *vlistptr, void *context);
static void vlistPackP (void *vlistptr, void *buff, int size,
int *position, void *context);
static int vlistTxCode (void);
#if !defined(__cplusplus)
const
......
......@@ -141,8 +141,6 @@ int vlistInqVarValidrange(int vlistID, int varID, double *validrange);
void vlistInqVarDimorder(int vlistID, int varID, int (*outDimorder)[3]);
int cdi_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB, int attnum);
void resize_opt_grib_entries(var_t *var, int nentries);
......
......@@ -1949,7 +1949,7 @@ int vlistVarCompare(vlist_t *a, int varIDA, vlist_t *b, int varIDB)
size_t natts = a->vars[varIDA].atts.nelems;
if (natts != b->vars[varIDB].atts.nelems) return 1;
for (size_t attID = 0; attID < natts; ++attID)
diff |= cdi_att_compare(a, varIDA, b, varIDB, (int)attID);
diff |= cdi_att_compare(&a->vars[varIDA].atts, &b->vars[varIDB].atts, (int)attID);
size_t nkeys = a->vars[varIDA].keys.nelems;
if (nkeys != b->vars[varIDB].keys.nelems) return 1;
......
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