Comment 116 for bug 1142213

Revision history for this message
In , Hugo Pereira Da Costa (hugo-pereira) wrote :

@Ruslan
Thanks for fixing. My bad.
Too bad I was fixing at the same time.
So now: using size *=2, rather than incrementing linearly the size is known to be more efficient algorithmically. So I'd rather push that. (will do on top of your changes after first discarding the ones I was about to push)

Concerning the use of std::string.
There is No conversion from const char* to std::string in the current code
the call runCommand( "..." ) implicitely calls the std::string directly
as for the call string.c_str() it access directly the const char* stored internally in the string

the advantage of using std::string instead of const char* is that it is freed automatically. You do not need to call neither malloc nor free anywhere. In the current code it makes no difference (but not overhead either), but it might makes some future use of the same method.
All in all, that's the whole idea behind using c++ instead of c, and limit c to where you have to (namely when calling gtk, glib or other functions).