Article View: borland.public.cppbuilder.nativeapi
Article #11706Re: std::string to BSTR conversion function leaks memory... (Urgent please)
From: Remy Lebeau (TeamB)
Date: Mon, 19 Jan 2004 21:25
Date: Mon, 19 Jan 2004 21:25
23 lines
1506 bytes
1506 bytes
"Fernando" <frr@easyjob.net> wrote in message
news:bjlf005pg85nvabmpc7ksd5ugs624tua53@4ax.com...
> BSTR string2BSTR( const string & input )
> {
You could simplify that code to the following instead:
BSTR string2BSTR( const string & input )
{
return SysAllocStringByteLen(input.c_str(), input.size());
}
Alternatively:
BSTR string2BSTR( const string & input )
{
return WideString(input.c_str(), input.size()).Detach();
}
Gambit
Technical Details
Message-ID:
<400c49ac$3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<bjlf005pg85nvabmpc7ksd5ugs624tua53@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,61db49fd5c05f5b0 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-01-19 13:22:05 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <bjlf005pg85nvabmpc7ksd5ugs624tua53@4ax.com> Subject: Re: std::string to BSTR conversion function leaks memory... (Urgent please) Date: Mon, 19 Jan 2004 13:25:05 -0800 Lines: 25 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <400c49ac$3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1074547116 67.22.138.253 (19 Jan 2004 13:18:36 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail