Re: Problem with cmods
"Per Hedbor () @ Pike (-) importm?te f?r mailinglistan" <[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 won't pretend I simply know if push_string or ref_push_string is needed > in your case. push_string, new strings start of with one reference, so ref_push_string would give it one extra. > The free() you do doesn't look good at all. It is needed, though, if s was allocated using malloc at some point, and you have the responsibility to free it. make_shared_string creates a copy of the passed char*. -- Per Hedbor