in reply to Re: C vs perl
in thread C vs perl

Says broquaint:
/* ok, this could be done better but it's only a string ;-) */ ret = (char*) malloc(strlen(str) + strlen(str));
String or not, it's clear that if you were going to do that, you should have done this instead:
ret = (char*) malloc(strlen(str) * 2);
Also, your function does not work. (I think you forgot to test it before you posted.) You need to have
pret += 7;
in the if block.

--
Mark Dominus
Perl Paraphernalia

Replies are listed 'Best First'.
Re: Re: C vs perl
by broquaint (Abbot) on Apr 28, 2002 at 15:08 UTC
    Also, your function does not work. (I think you forgot to test it before you posted.)
    I'd walked away from the computer and was going about my rainy afternoon before a little light-bulb appeared over my head and I ran back to add the offending line in hope that no one would notice. But the *second* I saw you in Other Users I knew it was coming ;-)

    A lesson learned for the day - think before posting kids.

    _________
    broquaint