From 7b80350c347089f64e67c0b950da6ca3aac0fd30 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 13 Jun 2008 16:21:36 +0000 Subject: [PATCH] possible fix for "too many file descriptors" bug reported on mailing list --- contrib/Netgen/nglib_addon.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/contrib/Netgen/nglib_addon.cpp b/contrib/Netgen/nglib_addon.cpp index ad01859d3b..51527333fa 100644 --- a/contrib/Netgen/nglib_addon.cpp +++ b/contrib/Netgen/nglib_addon.cpp @@ -41,7 +41,7 @@ class mystreambuf: public streambuf int overflow(int ch){ if(index < 1023){ txt[index] = ch; - if(txt[index] == '\n') txt[index] = ' '; + if(txt[index] == '\n' || txt[index] == '\r') txt[index] = ' '; if(!index && txt[0] == ' '){ // skip initial spaces } @@ -59,10 +59,13 @@ void NgAddOn_Init() //mycout = &cout; //myerr = &cerr; //testout = new ofstream ("test.out"); - - mycout = new ostream(new mystreambuf()); - myerr = new ostream(new mystreambuf()); - testout = new ofstream("/dev/null"); + static bool first = true; + if(first){ + first = false; + mycout = new ostream(new mystreambuf()); + myerr = new ostream(new mystreambuf()); + testout = new ofstream("/dev/null"); + } } // generates volume mesh from surface mesh, without optimization -- GitLab