Re: Problem with cmods
"Stephen R. van den Berg" <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <[email protected]> |
Christian Toepp 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);
I never used make_shared_string() directly.
In my own code I see a bunch of ref_push_string(MK_STRING("somestaticstring"))
references though (PGsql.cmod).
I won't pretend I simply know if push_string or ref_push_string is needed
in your case; but if you see a memory leak, that's a good thing to
try and switch (one or the other will increment the refcount). The free()
you do doesn't look good at all.
--
Stephen.