Re: Problem with cmods

Chris Angelico <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <CAPTjJmpm1hrREuKwz17RctFHcgbNzoD20_iUCri+ZyMTYMHAwg@mail.gmail.com>
On Thu, Mar 27, 2014 at 12:39 AM, Christian Toepp <[email protected]> wrote:
> Next: i see push_string(make_shared_string(s)) in your answer. after
> debugging and checking the code with valgrind i have to say that this is
> not useful because it is a possible memory leak. better is:
>
> struct pike_string *ret;
> ret = make_shared_string(s);
> free(s);
> push_string(ret);
>
> it seems that make_shared_string() creates a copy of your char* and its
> up to you to free your memory.

*rubs chin thoughtfully*

Hmm. That assumes that s was malloc'd, lemme check the docs for the
functions I'm using here. I'm pretty sure they return a pointer to a
preallocated buffer.

But if I do have a memory leak, that would explain some of the issues
I've been having. I'll try to get a moment to valgrind the module at
some point. (So much time, so little to do! Wait. Reverse that.)

ChrisA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.