HomerReid / scuff-em

A comprehensive and full-featured computational physics suite for boundary-element analysis of electromagnetic scattering, fluctuation-induced phenomena (Casimir forces and radiative heat transfer), nanophotonics, RF device engineering, electrostatics, and more. Includes a core library with C++ and python APIs as well as many command-line applications.
http://www.homerreid.com/scuff-em
GNU General Public License v2.0
125 stars 50 forks source link

prevent AppendEnv from adding the same path multiple times #183

Closed WenjieYao closed 5 years ago

WenjieYao commented 5 years ago

The RWGGeometry constructor calls the AppendEnv function from libhrutil to add a directory to the SCUFF_MESH_PATH environment variable. However, if you create many geometries in a loop (e.g. for optimization), this means that the same mesh path is appended to the environment over and over, eventually aborting because it overflows the buffer array.

This PR fixes the issue: it modifies AppendEnv to check whether the new path is already present in the Old environment variable (and is surrounded on either side by the Separator or by the ends of the string). If so, it returns without modifying the environment.

HomerReid commented 5 years ago

Thanks for addressing this!