MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmtapi_alloc_grid

Function gmtapi_alloc_grid

src/gmt_api.c:639–655  ·  view source on GitHub ↗

! . */

Source from the content-addressed store, hash-verified

637
638/*! . */
639GMT_LOCAL int gmtapi_alloc_grid (struct GMT_CTRL *GMT, struct GMT_GRID *G) {
640 /* Use information in Grid header to allocate the grid data array.
641 * We assume gmtapi_init_grdheader has already been called. */
642 struct GMT_GRID_HIDDEN *GG = NULL;
643 struct GMT_GRID_HEADER_HIDDEN *GH = NULL;
644
645 if (G == NULL) return (GMT_PTR_IS_NULL);
646 if (G->data) return (GMT_PTR_NOT_NULL);
647 if (G->header->size == 0U) return (GMT_SIZE_IS_ZERO);
648 if ((G->data = gmt_M_memory_aligned (GMT, NULL, G->header->size, gmt_grdfloat)) == NULL) return (GMT_MEMORY_ERROR);
649 GH = gmt_get_H_hidden (G->header);
650 GH->orig_datatype = (sizeof (gmt_grdfloat) == sizeof (float)) ? GMT_FLOAT : GMT_DOUBLE;
651 GG = gmt_get_G_hidden (G);
652 GG->alloc_mode = GMT_ALLOC_INTERNALLY; /* Memory can be freed by GMT. */
653 GG->alloc_level = GMT->hidden.func_level; /* Must be freed at this level. */
654 return (GMT_NOERROR);
655}
656
657/*! . */
658GMT_LOCAL double * gmtapi_grid_coord (struct GMTAPI_CTRL *API, int dim, struct GMT_GRID *G) {

Callers 1

GMT_Create_DataFunction · 0.85

Calls 2

gmt_get_H_hiddenFunction · 0.85
gmt_get_G_hiddenFunction · 0.85

Tested by

no test coverage detected