Commit 4731959a authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Prevent unnecessary string copy.

parent a372c1d1
......@@ -4121,6 +4121,12 @@ int gridInqReference(int gridID, char *reference)
return (len);
}
const char *gridInqReferencePtr(int gridID)
{
grid_t *gridptr = gridID2Ptr(gridID);
return gridptr->reference;
}
/*
@Function gridDefUUID
@Title Define the UUID for an unstructured grid
......
......@@ -132,6 +132,8 @@ const double *gridInqAreaPtr(int gridID);
const char *gridInqXnamePtr(int gridID);
const char *gridInqYnamePtr(int gridID);
const char *gridInqReferencePtr(int gridID);
int gridCompare(int gridID, const grid_t *grid);
int gridGenerate(const grid_t *grid);
......
......@@ -1740,14 +1740,9 @@ void cdfDefGridReference(stream_t *streamptr, int gridID)
cdf_put_att_int(fileID, NC_GLOBAL, "number_of_grid_used", NC_INT, 1, &number);
}
if ( gridInqReference(gridID, NULL) )
{
char gridfile[8912];
gridInqReference(gridID, gridfile);
if ( gridfile[0] != 0 )
cdf_put_att_text(fileID, NC_GLOBAL, "grid_file_uri", strlen(gridfile), gridfile);
}
const char *gridfile = gridInqReferencePtr(gridID);
if ( gridfile && gridfile[0] != 0 )
cdf_put_att_text(fileID, NC_GLOBAL, "grid_file_uri", strlen(gridfile), gridfile);
}
static
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment