fixed null stride problem for vars calls

This commit is contained in:
Ed Hartnett 2018-12-31 07:36:39 -07:00
parent b16eceabe2
commit 091880fd4d
2 changed files with 7 additions and 2 deletions

View File

@ -699,10 +699,10 @@ NC_check_nulls(int ncid, int varid, const size_t *start, size_t **count,
{
int i;
if (!(*stride = malloc(varndims * sizeof(size_t))))
if (!(*stride = malloc(varndims * sizeof(ptrdiff_t))))
return NC_ENOMEM;
for (i = 0; i < varndims; i++)
*stride[i] = 1;
(*stride)[i] = 1;
}
return NC_NOERR;

View File

@ -387,6 +387,7 @@ main(int argc, char **argv)
{
int ncid, dimid[NDIMS2], varid;
size_t start[NDIMS2] = {0, 0}, count[NDIMS2] = {NX, NY};
ptrdiff_t stride[NDIMS2] = {1, 1};
double double_data[NX * NY];
/* Create file with two dims, one 2D var. */
@ -400,6 +401,10 @@ main(int argc, char **argv)
if (nc_put_vara_double(ncid + MILLION, 0, start, count, double_data) != NC_EBADID) ERR;
if (nc_put_vara_double(ncid + TEST_VAL_42, 0, start, count, double_data) != NC_EBADID) ERR;
/* Write some data. */
if (nc_put_vars_double(ncid, varid, start, count, NULL, double_data)) ERR;
if (nc_put_vars_double(ncid, varid, start, count, stride, double_data)) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;