mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
abort
This commit is contained in:
parent
29e7bb2723
commit
ec43745ee9
@ -77,7 +77,7 @@ extern NC* find_in_NCList(int ext_ncid);
|
||||
extern NC* find_in_NCList_by_name(const char*);
|
||||
extern void free_NCList(void);/* reclaim whole list */
|
||||
extern int count_NCList(void); /* return # of entries in NClist */
|
||||
extern int iterate_NCList(int i,NC**); /* Walk from 0 ...; ERANGE return => stop */
|
||||
extern NC* iterate_NCList(int* i); /* Walk from 0 ...; NULL return => stop */
|
||||
|
||||
/* Defined in nc.c */
|
||||
extern void free_NC(NC*);
|
||||
|
@ -117,12 +117,25 @@ find_in_NCList_by_name(const char* path)
|
||||
return f;
|
||||
}
|
||||
|
||||
int
|
||||
iterate_NCList(int index, NC** ncp)
|
||||
NC*
|
||||
iterate_NCList(int* indexp)
|
||||
{
|
||||
/* Walk from 0 ...; 0 return => stop */
|
||||
int index = *indexp;
|
||||
NC* ncp = NULL;
|
||||
|
||||
if(nc_filelist == NULL || numfiles == 0)
|
||||
return NULL;
|
||||
if(index < 0 || index >= NCFILELISTLENGTH)
|
||||
return NC_ERANGE;
|
||||
if(ncp) *ncp = nc_filelist[index];
|
||||
return NC_NOERR;
|
||||
return NULL;
|
||||
for(;index < NCFILELISTLENGTH;index++) {
|
||||
if(nc_filelist[index] != NULL) {
|
||||
ncp = nc_filelist[index];
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
index = NCFILELISTLENGTH; /* no point in iterating further */
|
||||
ncp = NULL;
|
||||
done:
|
||||
*indexp = index;
|
||||
return ncp;
|
||||
}
|
||||
|
@ -132,17 +132,30 @@ for every known dispatch table.
|
||||
So if you modify the format of NC_Dispatch,
|
||||
then you need to fix it everywhere.
|
||||
It also finalizes appropriate external libraries.
|
||||
If there are open files when this is called, then
|
||||
all of those open files are aborted.
|
||||
*/
|
||||
|
||||
int
|
||||
nc_finalize(void)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
int index;
|
||||
NC* ncp;
|
||||
|
||||
if(NC_finalized) return NC_NOERR;
|
||||
NC_initialized = 0;
|
||||
NC_finalized = 1;
|
||||
|
||||
/* Abort any open files */
|
||||
index = 0;
|
||||
ncp = NULL;
|
||||
for(;;) { *
|
||||
ncp = iterate_NCList(&index);
|
||||
if(ncp == NULL) break;
|
||||
(void)nc_abort(ncp->ext_ncid); /* don't care if fails */
|
||||
}
|
||||
|
||||
/* Finalize each active protocol */
|
||||
|
||||
#ifdef ENABLE_DAP2
|
||||
|
@ -50,9 +50,7 @@ main(int argc, char **argv)
|
||||
#ifndef DEBUG
|
||||
/* Create a file */
|
||||
if((stat = nc_create(NCFILE,NC_CLOBBER|NC_NETCDF4,&ncid))) ERR; /* Indirectly call nc_initialize() */
|
||||
/* Force file to be written */
|
||||
// if((stat = nc_def_dim(ncid,"ignore",10,NULL))) ERR;
|
||||
if((stat = nc_close(ncid))) ERR;
|
||||
/* Leave file open to force finalize to abort it */
|
||||
if((stat = nc_finalize())) ERR;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user