Skip to content

make output pointers (vectors content and size) optional in the c api

Jonathan Lambrechts requested to merge optional_pointers_c_api into master

This commit allows to lighten the c api calls when the caller is only interested in a few of the returned values (besides, the vector size are sometimes redundant). For example, if we only want the coordinates of all nodes, we can use:

size_t n_nodes;
double *coords;
gmshModelMeshGetNodes(NULL, &n_nodes, &coords, NULL, NULL, NULL, -1, -1, 0, 0, &ierr); chkerr(ierr);
...
free(coords);

instead of:

size_t n_nodes, n_nodes_coord, n_nodes_param_coord, *nodes_tag;
double *coords, *param_coords;
gmshModelMeshGetNodes(&nodes_tag, &n_nodes, &coords, &n_nodes_coord, &param_coords, &n_nodes_param_coord, -1, -1, 0, 0, &ierr); chkerr(ierr);
free(nodes_tag);
free(param_coords);
...
free(coords);

Merge request reports