mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
removed more memory use for netcdf-4 performance
This commit is contained in:
parent
8131df9f40
commit
a106e959bc
@ -763,6 +763,8 @@ nc4_grp_list_add(NC_GRP_INFO_T **list, int new_nc_grpid,
|
||||
/* Fill in this group's information. */
|
||||
(*grp)->nc_grpid = new_nc_grpid;
|
||||
(*grp)->parent = parent_grp;
|
||||
if (!((*grp)->name = malloc((strlen(name) + 1) * sizeof(char))))
|
||||
return NC_ENOMEM;
|
||||
strcpy((*grp)->name, name);
|
||||
(*grp)->file = nc;
|
||||
|
||||
@ -867,8 +869,13 @@ nc4_field_list_add(NC_FIELD_INFO_T **list, int fieldid, const char *name,
|
||||
field->nctype = xtype;
|
||||
field->offset = offset;
|
||||
field->ndims = ndims;
|
||||
for (i = 0; i < ndims; i++)
|
||||
field->dim_size[i] = dim_sizesp[i];
|
||||
if (ndims)
|
||||
{
|
||||
if (!(field->dim_size = malloc(ndims * sizeof(int))))
|
||||
return NC_ENOMEM;
|
||||
for (i = 0; i < ndims; i++)
|
||||
field->dim_size[i] = dim_sizesp[i];
|
||||
}
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
@ -1002,9 +1009,11 @@ field_list_del(NC_FIELD_INFO_T **list, NC_FIELD_INFO_T *field)
|
||||
if(field->next)
|
||||
field->next->prev = field->prev;
|
||||
|
||||
/* Free the name. */
|
||||
/* Free some stuff. */
|
||||
if (field->name)
|
||||
free(field->name);
|
||||
if (field->dim_size)
|
||||
free(field->dim_size);
|
||||
|
||||
/* Nc_Free the memory. */
|
||||
free(field);
|
||||
@ -1192,6 +1201,9 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
|
||||
if (grp->hdf_grpid && H5Gclose(grp->hdf_grpid) < 0)
|
||||
return NC_EHDFERR;
|
||||
|
||||
/* Free the name. */
|
||||
free(grp->name);
|
||||
|
||||
/* Finally, redirect pointers around this entry in the list, and
|
||||
* nc_free its memory. */
|
||||
grp_list_del(list, grp);
|
||||
|
@ -191,7 +191,7 @@ typedef struct NC_FIELD_INFO
|
||||
char *name;
|
||||
int fieldid;
|
||||
int ndims;
|
||||
int dim_size[NC_MAX_VAR_DIMS];
|
||||
int *dim_size;
|
||||
} NC_FIELD_INFO_T;
|
||||
|
||||
typedef struct NC_ENUM_MEMBER_INFO
|
||||
@ -239,7 +239,7 @@ typedef struct NC_GRP_INFO
|
||||
int ndims;
|
||||
int natts;
|
||||
struct NC_FILE_INFO *file;
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char *name;
|
||||
hid_t hdf_grpid;
|
||||
NC_TYPE_INFO_T *type;
|
||||
} NC_GRP_INFO_T;
|
||||
|
Loading…
Reference in New Issue
Block a user