示例#1
0
/* Read a NC_dim from the header */
static int
v1h_get_NC_dim(v1hs *gsp, NC_dim **dimpp)
{
	int status;
	NC_string *ncstrp;
	NC_dim *dimp;

	status = v1h_get_NC_string(gsp, &ncstrp);
	if(status != ENOERR)
		return status;

	dimp = new_x_NC_dim(ncstrp);
	if(dimp == NULL)
	{
		status = NC_ENOMEM;
		goto unwind_name;
	}

	status = v1h_get_size_t(gsp, &dimp->size);
	if(status != ENOERR)
	{
		free_NC_dim(dimp); /* frees name */
		return status;
	}

	*dimpp = dimp;

	return ENOERR;

unwind_name:
	free_NC_string(ncstrp);
	return status;
}
示例#2
0
文件: dim.c 项目: BJangeofan/netcdf-c
/*
 * Formerly
NC_new_dim(const char *uname, long size)
 */
static NC_dim *
new_NC_dim(const char *uname, size_t size)
{
	NC_string *strp;
	NC_dim *dimp;

	char *name = (char *)utf8proc_NFC((const unsigned char *)uname);
	if(name == NULL)
	    return NULL;
	strp = new_NC_string(strlen(name), name);
	free(name);
	if(strp == NULL)
		return NULL;

	dimp = new_x_NC_dim(strp);
	if(dimp == NULL)
	{
		free_NC_string(strp);
		return NULL;
	}

	dimp->size = size;

	return(dimp);
}
示例#3
0
文件: dim.c 项目: dschwen/libmesh
/*
 * Formerly
NC_new_dim(const char *uname, long size)
 */
static NC_dim *
new_NC_dim(const char *uname, size_t size)
{
	NC_string *strp;
	NC_dim *dimp = NULL;
	int stat = NC_NOERR;
	char* name = NULL;

	stat = nc_utf8_normalize((const unsigned char *)uname,(unsigned char **)&name);
	if(stat != NC_NOERR)
	    goto done;
	strp = new_NC_string(strlen(name), name);
	if(strp == NULL)
		{stat = NC_ENOMEM; goto done;}

	dimp = new_x_NC_dim(strp);
	if(dimp == NULL)
	{
		free_NC_string(strp);
		goto done;
	}

	dimp->size = size;

done:
	if(name) free(name);
	return (dimp);
}