mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Removing reliance on NC_MAX_VAR_DIMS
This commit is contained in:
parent
23647a6910
commit
fae7d90194
@ -170,7 +170,9 @@ nc4_pg_var1(NC_PG_T pg, NC *nc, int ncid, int varid,
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_VAR_INFO_T *var;
|
||||
int i;
|
||||
size_t start[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
|
||||
size_t *start = NULL;
|
||||
size_t *count = NULL;
|
||||
|
||||
int retval;
|
||||
|
||||
/* Find file and var, cause I need the number of dims. */
|
||||
@ -179,22 +181,37 @@ nc4_pg_var1(NC_PG_T pg, NC *nc, int ncid, int varid,
|
||||
return retval;
|
||||
assert(grp && var && var->name);
|
||||
|
||||
if(!(start = (size_t*)malloc(sizeof(size_t)*var->ndims))) {
|
||||
return NC_ENOMEM;
|
||||
}
|
||||
|
||||
if(!(count = (size_t*)malloc(sizeof(size_t)*var->ndims))) {
|
||||
free(start);
|
||||
return NC_ENOMEM;
|
||||
}
|
||||
|
||||
|
||||
/* Set up the count and start arrays. */
|
||||
for (i=0; i<var->ndims; i++)
|
||||
{
|
||||
start[i] = indexp[i];
|
||||
count[i] = 1;
|
||||
start[i] = indexp[i];
|
||||
count[i] = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Get or put this data. */
|
||||
if (pg == GET)
|
||||
return nc4_get_vara(nc, ncid, varid, start, count, xtype,
|
||||
is_long, ip);
|
||||
else
|
||||
return nc4_put_vara(nc, ncid, varid, start, count, xtype,
|
||||
int res = 0;
|
||||
if (pg == GET) {
|
||||
res = nc4_get_vara(nc, ncid, varid, start, count, xtype,
|
||||
is_long, ip);
|
||||
} else {
|
||||
res = nc4_put_vara(nc, ncid, varid, start, count, xtype,
|
||||
is_long, ip);
|
||||
}
|
||||
free(start);
|
||||
free(count);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* Get the default fill value for an atomic type. Memory for
|
||||
* fill_value must already be allocated, or you are DOOMED!!!*/
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user