edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] JS_smprintf
@ 2013-12-24 18:44 Karl Dahlke
  0 siblings, 0 replies; only message in thread
From: Karl Dahlke @ 2013-12-24 18:44 UTC (permalink / raw)
  To: Edbrowse-dev

It looks like JS_smprintf is a version of sprint that allocates
a string long enough to hold the expanded message, so you don't have to worry
about a big enough char buffer, like you do with sprintf.
All good, but it's allocated, and so has to be freed.

Then js had its own heap within itself, that may or may not be known to malloc,
so I had to call JS_free(cx, string);
I don't think you can just call free.
There's a lot of this in my_errorReporter().

Then I read somewhere that I was suppose to use explicitly JS_smprintf_free
to free up these sprintf lines.
So I guess I used that in jsloc.c, but never in jsdom.c
Inconsistent, and yet it all seems to work.
I probably could have used js_free everywhere.

I don't even know if we need to do this at all, any more,
or if the c++ version has a better garbage collector.
Probably we still have to do it, because the gc would have no idea
when we were done with those strings, as allocated by js_sprintf.

That's the history of it as best I can paste together from my memory
and fromlooking at the code.

Karl Dahlke

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-24 18:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-24 18:44 [Edbrowse-dev] JS_smprintf Karl Dahlke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).