[Code Review] Wrote a fast binary STL inspector/analyzer in C – looking for feedback on memory management and math logic

Wait 5 sec.

Hi everyone, I've been working on a lightweight CLI tool in C called stl-inspector (GitHub repo). Why I built it: I got tired of waiting for heavy slicers (PrusaSlicer, Cura, Bambu Studio) just to check basic parameters like watertightness, mesh volume, overhang areas, and bounding dimensions of 3D models. What it currently does: Parses binary STL headers and triangle arrays Calculates bounding box, volume (tetrahedron method), and surface area Detects overhang areas (default 45°) for 3D printing feasibility Checks if the mesh is watertight Fast build with zero external dependencies (pure C + Makefile) Where I'd appreciate feedback: Memory safety & cleanup (handling large meshes) Performance of the watertight check (currently O(N^2), looking into spatial hashing / edge mapping) General C code idiomatic style and CLI argument handling Note: AI was used to help debug directory creation. Would love to hear your critique or suggestions for improvement.   submitted by   /u/wajlem   to   r/C_Programming [link]   [comments]