Rather than creating new geometric primitives on the heap, wouldn't it be more flexible if the caller can provide the memory to initialize the structure in?<p>Then instead of<p><pre><code> struct tg_geom *geom = tg_geom_new_point(-112, 33);
if (!geom) {
// System is out of memory.
}
</code></pre>
you could do<p><pre><code> struct tg_geom geom;
tg_geom_init_point(&geom, -112, 33);
</code></pre>
without need for error checking or cleanup. You can still allocate on the heap if you want but you wouldn't have to.