On Wed, Apr 6, 2011 at 9:30 AM, Russell Bryant
<russell(a)russellbryant.net> wrote:
On Wed, Apr 6, 2011 at 7:13 AM, Andrew Beekhof
<andrew(a)beekhof.net> wrote:
> On Wed, Apr 6, 2011 at 1:50 PM, Russell Bryant
> <russell(a)russellbryant.net> wrote:
>> On Wed, Apr 6, 2011 at 2:29 AM, Andrew Beekhof <andrew(a)beekhof.net> wrote:
>>> On Tue, Apr 5, 2011 at 12:54 AM, Russell Bryant
>>> <russell(a)russellbryant.net> wrote:
>>>> On Mon, Apr 4, 2011 at 5:29 AM, Andrew Beekhof <andrew(a)beekhof.net>
wrote:
>>>>> But specifically in this case, where the input is a char* and the
>>>>> usage is as a char*, it doesn't make much sense to store it as a
C++
>>>>> string in between.
>>>>
>>>> Wellll ... except that the whole point is that it does the memory
>>>> management for you to avoid having the type of problem I fixed.
>>>
>>> except optarg is a const char *, so no mem management necessary :)
>>
>> Sure, optarg is, but not where it was being copied to. The problems
>> were the strdup()s of optarg. That's (unnecessary) manual memory
>> management.
>
> Ok, then just drop the strdup()
>
How dare you come up with a simple solution to a problem we were
having so much fun over-complicating! :-)
Sounds good.
I finally went back to update this ... it's not that simple. You
can't just drop the strdup(). There is some windows code mixed in
here and in that case, it's using RegistryRead(). There's no simple
saving off of a const char * in that case.
I just changed it back to strdup() and such and added free() as needed
(even though I still think std::string is better :-p).
--
Russell Bryant