star-cad

Geometric operators for computer-aided design
git clone git://git.meso-star.fr/star-cad.git
Log | Files | Refs | README | LICENSE

commit e1be928cc0a4bac21c94c895dff4db7de4bcc4bb
parent 5136bcab8f6771f1c42fb221bf46a246cb0e0210
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date:   Wed, 15 Feb 2023 14:10:40 +0100

Bugfix when null intersection between geometries

Diffstat:
Msrc/scad_geometry.c | 28++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/scad_geometry.c b/src/scad_geometry.c @@ -1039,12 +1039,16 @@ scad_intersect_geometries ERR(scad_geometry_create(name, &geom)); geom->gmsh_dimTags_n = tagoutn; - geom->gmsh_dimTags = MEM_ALLOC(allocator, tagoutn * sizeof(*tagout)); - if(!geom->gmsh_dimTags) { - res = RES_MEM_ERR; - goto error; + if (tagoutn == 0){ + geom->gmsh_dimTags = NULL; + } else { + geom->gmsh_dimTags = MEM_ALLOC(allocator, tagoutn * sizeof(*tagout)); + if(!geom->gmsh_dimTags) { + res = RES_MEM_ERR; + goto error; + } + memcpy(geom->gmsh_dimTags, tagout, tagoutn * sizeof(*tagout)); } - memcpy(geom->gmsh_dimTags, tagout, tagoutn * sizeof(*tagout)); ERR(device_register_tags(geom)); @@ -1118,12 +1122,16 @@ scad_geometries_common_boundaries ERR(scad_geometry_create(name, &geom)); geom->gmsh_dimTags_n = tagoutn; - geom->gmsh_dimTags = MEM_ALLOC(allocator, tagoutn * sizeof(*tagout)); - if(!geom->gmsh_dimTags) { - res = RES_MEM_ERR; - goto error; + if (tagoutn == 0) { + geom->gmsh_dimTags = NULL; + } else { + geom->gmsh_dimTags = MEM_ALLOC(allocator, tagoutn * sizeof(*tagout)); + if(!geom->gmsh_dimTags) { + res = RES_MEM_ERR; + goto error; + } + memcpy(geom->gmsh_dimTags, tagout, tagoutn * sizeof(*tagout)); } - memcpy(geom->gmsh_dimTags, tagout, tagoutn * sizeof(*tagout)); ERR(device_register_tags(geom));