beaver-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Beaver-devel] str_replace_tokens


From: Michael Terry
Subject: Re: [Beaver-devel] str_replace_tokens
Date: Fri, 06 Jun 2003 16:08:51 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030322

Leslie Polzer wrote:
I don't know if you did this function, but maybe you can answer my
question nevertheless. Prototype is:

        gchar *str_replace_tokens (gchar **string, gchar obj,
                gchar *replacement)

Why's string a gchar** and not just a simple gchar* ? I don't see
any sensible reason for it, it's always referred to as *string anyway.

Yeah, I am responsible.

The reason is so that I can write
str_replace_tokens (&str, 'l', "hi");

instead of
str = str_replace_tokens (str, 'l', "hi");

That's all, to my knowledge. Since the function actually realloc's the string, you would never assign the return to anything but the same pointer.

Of course, then the question is why realloc instead of malloc. I knew how I was going to use the function, and I knew that it would be simpler for me if I realloc'ed (because otherwise I would have to free the old string, which I never care about anyway).

Feel free to change it.

-mt

Attachment: pgpza6gsI8Iip.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]