mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-09 08:11:38 +08:00
switch
This commit is contained in:
parent
979873f81d
commit
e40eb2e950
@ -53,12 +53,16 @@ Free a list and its contents
|
||||
int
|
||||
nclistfreeall(NClist* l)
|
||||
{
|
||||
size_t i;
|
||||
size_t i,len;
|
||||
void** content = NULL;
|
||||
if(l == NULL) return TRUE;
|
||||
for(i=0;i<l->length;i++) {
|
||||
void* value = l->content[i];
|
||||
len = l->length;
|
||||
content = nclistextract(l);
|
||||
for(i=0;i<len;i++) {
|
||||
void* value = content[i];
|
||||
if(value != NULL) free(value);
|
||||
}
|
||||
if(content != NULL) free(content);
|
||||
return nclistfree(l);
|
||||
}
|
||||
|
||||
|
@ -208,6 +208,7 @@ nc4_close_netcdf4_file(NC_FILE_INFO_T *h5, int abort, NC_memio* memio)
|
||||
* hidden attribute. */
|
||||
if (h5->provenance)
|
||||
NC4_free_provenance(h5->provenance);
|
||||
h5->provenance = NULL; /* Avoid double dealloc */
|
||||
|
||||
/* Close hdf file. It may not be open, since this function is also
|
||||
* called by NC_create() when a file opening is aborted. */
|
||||
|
@ -64,17 +64,22 @@ NC4_provenance_init(void)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
|
||||
/* Insert primary library version as first entry */
|
||||
if((value = strdup(PACKAGE_VERSION)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
|
||||
if((name = strdup(NCPNCLIB2)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
nclistpush(globalpropinfo.properties,name);
|
||||
name = NULL;
|
||||
name = NULL; /* Avoid multiple free() */
|
||||
|
||||
if((value = strdup(PACKAGE_VERSION)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
nclistpush(globalpropinfo.properties,value);
|
||||
value = NULL;
|
||||
|
||||
/* Insert the HDF5 as underlying storage format library */
|
||||
if((name = strdup(NCPHDF5LIB2)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
nclistpush(globalpropinfo.properties,name);
|
||||
name = NULL;
|
||||
|
||||
stat = NC4_hdf5get_libversion(&major,&minor,&release);
|
||||
if(stat) goto done;
|
||||
{
|
||||
@ -83,10 +88,6 @@ NC4_provenance_init(void)
|
||||
if((value = strdup(sversion)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
}
|
||||
if((name = strdup(NCPHDF5LIB2)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
nclistpush(globalpropinfo.properties,name);
|
||||
name = NULL;
|
||||
nclistpush(globalpropinfo.properties,value);
|
||||
value = NULL;
|
||||
|
||||
@ -101,6 +102,8 @@ NC4_provenance_init(void)
|
||||
/* merge into the properties list */
|
||||
for(i=0;i<nclistlength(other);i++)
|
||||
nclistpush(globalpropinfo.properties,strdup(nclistget(other,i)));
|
||||
nclistfreeall(other);
|
||||
other = NULL;
|
||||
|
||||
done:
|
||||
if(name != NULL) free(name);
|
||||
@ -347,20 +350,25 @@ NC4_set_provenance(NC_FILE_INFO_T* file, const struct NCPROPINFO* dfalt)
|
||||
|
||||
/* Initialize from the default */
|
||||
provenance->propattr.version = globalpropinfo.version;
|
||||
provenance->propattr.properties = nclistnew();
|
||||
if(provenance->propattr.properties == NULL)
|
||||
{ncstat = NC_ENOMEM; goto done;}
|
||||
|
||||
/* Get the superblock number */
|
||||
if((ncstat = NC4_hdf5get_superblock(file,&superblock)))
|
||||
goto done;
|
||||
provenance->superblockversion = superblock;
|
||||
|
||||
/* Capture properties */
|
||||
provenance->propattr.properties = nclistnew();
|
||||
if(provenance->propattr.properties == NULL)
|
||||
{ncstat = NC_ENOMEM; goto done;}
|
||||
/* add in the dfalt values */
|
||||
if(dfalt != NULL) {
|
||||
int i;
|
||||
for(i=0;i<nclistlength(dfalt->properties);i++) {
|
||||
nclistpush(provenance->propattr.properties,nclistget(dfalt->properties,i));
|
||||
char* prop = nclistget(dfalt->properties,i);
|
||||
if(prop != NULL) {
|
||||
prop = strdup(prop);
|
||||
if(prop == NULL) {ncstat = NC_ENOMEM; goto done;}
|
||||
nclistpush(provenance->propattr.properties,prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,8 +480,9 @@ int
|
||||
NC4_free_provenance(struct NCPROVENANCE* prov)
|
||||
{
|
||||
if(prov == NULL) return NC_NOERR;
|
||||
if(prov->propattr.properties)
|
||||
if(prov->propattr.properties != NULL);
|
||||
nclistfreeall(prov->propattr.properties);
|
||||
prov->propattr.properties = NULL;
|
||||
free(prov);
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ typedef int ssize_t;
|
||||
#undef X_ALIGN
|
||||
#endif
|
||||
|
||||
#undef REALLOCBUG
|
||||
#define REALLOCBUG
|
||||
#ifdef REALLOCBUG
|
||||
/* There is some kind of realloc bug that I cannot solve yet */
|
||||
#define reallocx(m,new,old) realloc(m,new)
|
||||
@ -84,7 +84,10 @@ static void*
|
||||
reallocx(void* mem, size_t newsize, size_t oldsize)
|
||||
{
|
||||
void* m = malloc(newsize);
|
||||
memcpy(m,mem,oldsize);
|
||||
if(m != NULL) {
|
||||
memcpy(m,mem,oldsize);
|
||||
free(mem);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
#endif
|
||||
@ -334,6 +337,8 @@ memio_open(const char* path,
|
||||
|
||||
sizehint = *sizehintp;
|
||||
|
||||
memset(&meminfo,0,sizeof(meminfo));
|
||||
|
||||
if(inmemory) { /* parameters provide the memory chunk */
|
||||
NC_memio* memparams = (NC_memio*)parameters;
|
||||
meminfo = *memparams;
|
||||
@ -490,7 +495,8 @@ fprintf(stderr,"realloc: %lu/%lu -> %lu/%lu\n",
|
||||
|
||||
/*! Write out any dirty buffers to disk.
|
||||
|
||||
Write out any dirty buffers to disk and ensure that next read will get data from disk. Sync any changes, then close the open file associated with the ncio struct, and free its memory.
|
||||
Write out any dirty buffers to disk and ensure that next read will get data from disk.
|
||||
Sync any changes, then close the open file associated with the ncio struct, and free its memory.
|
||||
|
||||
@param[in] nciop pointer to ncio to close.
|
||||
@param[in] doUnlink if true, unlink file
|
||||
@ -632,8 +638,8 @@ memio_sync(ncio* const nciop)
|
||||
return NC_NOERR; /* do nothing */
|
||||
}
|
||||
|
||||
/* "Hidden" Internal function to extract a copy of
|
||||
the size and/or contents of the memory
|
||||
/* "Hidden" Internal function to extract the
|
||||
the size and/or contents of the memory.
|
||||
*/
|
||||
int
|
||||
memio_extract(ncio* const nciop, size_t* sizep, void** memoryp)
|
||||
@ -735,9 +741,11 @@ readfile(const char* path, NC_memio* memio)
|
||||
if(memio) {
|
||||
memio->size = (size_t)filesize;
|
||||
memio->memory = memory;
|
||||
}
|
||||
memory = NULL;
|
||||
}
|
||||
|
||||
done:
|
||||
if(status != NC_NOERR && memory != NULL)
|
||||
if(memory != NULL)
|
||||
free(memory);
|
||||
if(f != NULL) fclose(f);
|
||||
return status;
|
||||
|
@ -1,17 +1,17 @@
|
||||
# Test c output
|
||||
T=tst_diskless3
|
||||
T=tst_diskless5
|
||||
|
||||
#H58=8
|
||||
H510=10
|
||||
|
||||
ARGS=diskless persist
|
||||
#ARGS=diskless persist
|
||||
|
||||
#SRC=
|
||||
|
||||
#CMD=env HDF5_DEBUG=trace
|
||||
#CMD=export NETCDF_LOG_LEVEL=5 ;gdb --args
|
||||
CMD=valgrind --leak-check=full
|
||||
CMD=gdb --args
|
||||
#CMD=gdb --args
|
||||
|
||||
#PAR=1
|
||||
|
||||
@ -48,3 +48,10 @@ cmp::
|
||||
|
||||
cpp::
|
||||
${CC} -E ${CFLAGS} ${T}.c > ${T}.txt
|
||||
|
||||
#TS = tst_diskless tst_diskless2 tst_diskless3 tst_diskless4 tst_diskless5 tst_diskless6
|
||||
TS = tst_diskless5
|
||||
several::
|
||||
export LD_LIBRARY_PATH=${LLP}; export CFLAGS; export LDFLAGS; \
|
||||
for f in ${TS} ; do ${CC} -o ${TS} ${CFLAGS} ${TS}.c ${SRC} ${LDFLAGS}; done
|
||||
|
||||
|
@ -122,3 +122,13 @@ endif
|
||||
|
||||
# If valgrind is present, add valgrind targets.
|
||||
@VALGRIND_CHECK_RULES@
|
||||
|
||||
|
||||
|
||||
# For some reason, it appears that we need to make the .sh files
|
||||
# depend on the programs they run when doing check-valgrind
|
||||
run_diskless.sh: tst_diskless tst_diskless2 tst_diskless3
|
||||
run_diskless5.sh: tst_diskless5
|
||||
run_inmemory.sh: tst_inmemory tst_open_mem
|
||||
run_diskless2.sh: tst_diskless4
|
||||
run_cdf5.sh: tst_open_cdf5
|
||||
|
@ -23,7 +23,7 @@ AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
|
||||
LDADD = ${top_builddir}/liblib/libnetcdf.la
|
||||
|
||||
# These are netCDF-4 C test programs which are built and run.
|
||||
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
|
||||
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
|
||||
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \
|
||||
tst_grps2 tst_compounds tst_compounds2 tst_compounds3 tst_opaques \
|
||||
tst_strings tst_strings2 tst_interops tst_interops4 tst_interops5 \
|
||||
@ -151,3 +151,15 @@ DISTCLEANFILES = findplugin.sh
|
||||
|
||||
# If valgrind is present, add valgrind targets.
|
||||
@VALGRIND_CHECK_RULES@
|
||||
|
||||
# Keep check-valgrind happy
|
||||
run_grp_rename.sh: renamegroup
|
||||
run_empty_vlen_test.sh: tst_empty_vlen_unlim
|
||||
tst_szip.sh: test_szip h5testszip
|
||||
tst_filter.sh: test_filter test_filter_misc
|
||||
run_tst_chunks.sh: tst_chunks3
|
||||
run_knmi_bm.sh: tst_knm
|
||||
run_bm_test1.sh: bm_file
|
||||
run_bm_test2.sh: bm_file
|
||||
run_bm_elena.sh: bm_file
|
||||
perftest.sh: bigmeta openbigmeta
|
||||
|
Loading…
Reference in New Issue
Block a user