String and std::string
Alex Tibbles
alex_tibbles@yahoo.co.uk
Fri Mar 21 12:12:00 GMT 2003
<snip>
> I don't care whether you use std::string, or
> String++ for any new code,
> as long as:
> 1) You don't leak memory (std::string will leak if
> you use c_str())
> IIRC.
I've been unable to confirm this. I tried the attached
program (compiled with gcc -lstdc++ stringleak.cpp)
and got the following results from top:
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM
648 alex 14 0 556 556 416 R 56.2 0.2
TIME COMMAND
3:02 a.out
Am I correct in concluding that std::string::c_str()
does not leak? I'm interested as I use c_str() a fair
amount for interfacing C++ with C (I believe that was
what it was designed for, but I'm only guessing).
Regards,
Alex
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stringleak.cpp
URL: <http://cygwin.com/pipermail/cygwin-apps/attachments/20030321/87819ba1/attachment.ksh>
More information about the Cygwin-apps
mailing list