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

Function gmtapi_destroy_data_ptr

src/gmt_api.c:4219–4269  ·  view source on GitHub ↗

! . */

Source from the content-addressed store, hash-verified

4217
4218/*! . */
4219GMT_LOCAL int gmtapi_destroy_data_ptr (struct GMTAPI_CTRL *API, enum GMT_enum_family family, void *ptr) {
4220 /* Like GMT_Destroy_Data but takes pointer to data rather than address of pointer.
4221 * We pass true to make sure we free the memory. Some objects (grid, matrix, vector) may
4222 * point to externally allocated memory so we return the alloc_mode for those items.
4223 * This is mostly for information since the pointers to such external memory have now
4224 * been set to NULL instead of being freed.
4225 * The containers are always allocated by GMT so those are freed at the end.
4226 */
4227
4228 struct GMT_CTRL *GMT;
4229 if (API == NULL) return (GMT_NOT_A_SESSION);
4230 if (!ptr) return (GMT_NOERROR); /* Null pointer */
4231 GMT = API->GMT;
4232
4233 switch (family) {
4234 case GMT_IS_GRID:
4235 gmtlib_free_grid_ptr (GMT, ptr, true);
4236 break;
4237 case GMT_IS_DATASET:
4238 gmtlib_free_dataset_ptr (GMT, ptr);
4239 break;
4240 case GMT_IS_PALETTE:
4241 gmtlib_free_cpt_ptr (GMT, ptr);
4242 break;
4243 case GMT_IS_IMAGE:
4244 gmtlib_free_image_ptr (GMT, ptr, true);
4245 break;
4246 case GMT_IS_POSTSCRIPT:
4247 gmtlib_free_ps_ptr (GMT, ptr);
4248 break;
4249 case GMT_IS_CUBE:
4250 gmtlib_free_cube_ptr (GMT, ptr, true);
4251 break;
4252 case GMT_IS_COORD:
4253 /* Nothing to do as gmt_M_free below will do it */
4254 break;
4255
4256 /* Also allow destroying of intermediate vector and matrix containers */
4257 case GMT_IS_MATRIX:
4258 gmtlib_free_matrix_ptr (GMT, ptr, true);
4259 break;
4260 case GMT_IS_VECTOR:
4261 gmtlib_free_vector_ptr (GMT, ptr, true);
4262 break;
4263 default:
4264 return (gmtlib_report_error (API, GMT_NOT_A_VALID_FAMILY));
4265 break;
4266 }
4267 gmt_M_free (GMT, ptr); /* OK to free container */
4268 return (GMT_NOERROR); /* Null pointer */
4269}
4270
4271GMT_LOCAL void gmtapi_flip_vectors (struct GMT_CTRL *GMT, struct GMT_VECTOR *V, unsigned int direction) {
4272 enum GMT_enum_type etmp;

Callers 3

gmtapi_export_dataFunction · 0.85
GMT_Begin_IOFunction · 0.85

Calls 9

gmtlib_free_grid_ptrFunction · 0.85
gmtlib_free_dataset_ptrFunction · 0.85
gmtlib_free_cpt_ptrFunction · 0.85
gmtlib_free_image_ptrFunction · 0.85
gmtlib_free_ps_ptrFunction · 0.85
gmtlib_free_cube_ptrFunction · 0.85
gmtlib_free_matrix_ptrFunction · 0.85
gmtlib_free_vector_ptrFunction · 0.85
gmtlib_report_errorFunction · 0.85

Tested by

no test coverage detected