int ncaux_begin_compound(int ncid, const char *name, int alignmode, void** tagp) { int status = NC_NOERR; struct NCAUX_CMPD* cmpd = NULL; if(!ncaux_initialized) { compute_alignments(); ncaux_initialized = 1; } if(tagp) *tagp = NULL; cmpd = (struct NCAUX_CMPD*)calloc(1,sizeof(struct NCAUX_CMPD)); if(cmpd == NULL) { status = NC_ENOMEM; goto fail; } cmpd->ncid = ncid; cmpd->mode = alignmode; cmpd->nfields = 0; cmpd->name = strdup(name); if(cmpd->name == NULL) { status = NC_ENOMEM; goto fail; } if(tagp) *tagp = (void*)cmpd; return status; fail: ncaux_abort_compound((void*)cmpd); return status; }
EXTERNL int ncaux_begin_compound(int ncid, const char *name, int alignmode, void** tagp) { #ifdef USE_NETCDF4 int status = NC_NOERR; struct NCAUX_CMPD* cmpd = NULL; if(tagp) *tagp = NULL; cmpd = (struct NCAUX_CMPD*)calloc(1,sizeof(struct NCAUX_CMPD)); if(cmpd == NULL) {status = NC_ENOMEM; goto fail;} cmpd->ncid = ncid; cmpd->mode = alignmode; cmpd->nfields = 0; cmpd->name = strdup(name); if(cmpd->name == NULL) {status = NC_ENOMEM; goto fail;} if(tagp) { *tagp = (void*)cmpd; } else { /* Error, free cmpd to avoid memory leak. */ free(cmpd); } return status; fail: ncaux_abort_compound((void*)cmpd); return status; #else return NC_ENOTBUILT; #endif }