Article View: borland.public.cppbuilder.nativeapi
Article #4597Re: all IP adresses of the local system
From: Alan Bellingham
Date: Thu, 22 Dec 2005 17:08
Date: Thu, 22 Dec 2005 17:08
29 lines
1834 bytes
1834 bytes
"EB" <elias.berelian@snet.net> wrote: >How do you do this if you don't want to use boost::? > >ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO); > boost::scoped_array<char> pAdapterInfo( new char[ulOutBufLen] ); std::vector<char> pAdapterInfo(ulOutBufLen); And for passing the address to old API functions: char* ptr = &pAdapterInfo[0]; JB's solution should also work, but is overly verbose, overly obscures the code logic, and is overly fragile in comparison. >The following doesn't work: > char *pAdapterInfo( new char[ulOutBufLen] ); In what way doesn't it work? Compile time? Run time? Code review time? What or who doesn't like it? The BCB5 compiler appears to be perfectly happy with it, once I replaced the variable with an explicit value. Oh, and I recommend that you drop the 'ul' wart. Hungarian notation is really not useful in C++. Alan Bellingham -- ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK
Technical Details
Message-ID:
<8vmlq15bqgjvlg4mr28rar13054tsv7ub0@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<43a832cb$1@newsgroups.borland.com> <43aad18b@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,744a3315ee7b00aa X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Alan Bellingham <alanb@episys.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: all IP adresses of the local system Date: Thu, 22 Dec 2005 17:08:41 +0000 Reply-To: alanb@episys.com Message-ID: <8vmlq15bqgjvlg4mr28rar13054tsv7ub0@4ax.com> References: <43a832cb$1@newsgroups.borland.com> <43aad18b@newsgroups.borland.com> X-Newsreader: Forte Agent 3.1/32.783 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 193.129.251.253 X-Trace: newsgroups.borland.com 1135271224 193.129.251.253 (22 Dec 2005 09:07:04 -0700) Lines: 29 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail