edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Karl Dahlke <eklhad@comcast.net>
To: Edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] JS_smprintf
Date: Tue, 24 Dec 2013 13:44:03 -0500	[thread overview]
Message-ID: <20131124134403.eklhad@comcast.net> (raw)

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

                 reply	other threads:[~2013-12-24 18:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131124134403.eklhad@comcast.net \
    --to=eklhad@comcast.net \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).