From: Mikael Djurfeldt <mdj@mit.edu>
Cc: guile-user@gnu.org, djurfeldt@nada.kth.se, guile-devel@gnu.org
Subject: Re: About shared substrings
Date: Fri, 16 Jan 2004 16:54:51 -0500 [thread overview]
Message-ID: <xy7llo7tv84.fsf@chunk.mit.edu> (raw)
In-Reply-To: <1074285306.6739.178.camel@localhost> (Roland Orre's message of "Fri, 16 Jan 2004 21:35:06 +0100")
Roland Orre <orre@nada.kth.se> writes:
> I discussed this issue with Mikael Djurfeldt today and then he came up
> with the following solution:
>
> SCM substring_table;
>
> SCM scm_make_shared_substring (SCM parent, SCM start, SCM end)
> {
> SCM substring;
> char *mem;
> int c_start, c_end;
> SCM_VALIDATE_SUBSTRING_SPEC_COPY (1, parent, mem,
> 2, start, c_start,
> 3, end, c_end);
> substring = scm_cell (SCM_MAKE_STRING_TAG (c_end - c_start),
> (scm_t_bits) (mem + c_start));
> scm_hash_set_x (substring_table, substring, parent);
> return substring;
> }
>
> where the following is put in the main:
> substring_table
> = scm_permanent_object (scm_make_weak_key_hash_table (SCM_UNDEFINED));
>
> This is almost magical :)
Unfortunately, it *is* magical. In addition, it is necessary to hand
the newly created substring to a guardian. If we then add a hook
function to some suitable GC hook which loops through all unreferenced
substrings and sets their address pointer to NULL, everything should
work.
If we *don't* do that, the same area of memory will be freed
repeatedly, which is not optimal.
> Mikael Djurfeldt is relly the most clever programmer I know.
Many thanks for the kind words! Yes, I am usually a blazing genius.
My mistake above must certainly be due to something in my coffee or
so... :)
M
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2004-01-16 21:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1074242951.6739.5.camel@localhost>
[not found] ` <rmillo7u2pv.fsf@fnord.ir.bbn.com>
2004-01-16 20:35 ` About shared substrings Roland Orre
2004-01-16 21:12 ` Neil Jerram
2004-01-17 22:34 ` Keith Wright
2004-01-16 21:54 ` Mikael Djurfeldt [this message]
2004-01-16 22:00 ` Tom Lord
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xy7llo7tv84.fsf@chunk.mit.edu \
--to=mdj@mit.edu \
--cc=djurfeldt@nada.kth.se \
--cc=guile-devel@gnu.org \
--cc=guile-user@gnu.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).