Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: C vs perl

by Dominus (Parson)
on Apr 28, 2002 at 15:04 UTC ( [id://162663]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://162663]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-24 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found