unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Rob Browning <rlb@defaultvalue.org>
Subject: Re: make-regexp error memory leak
Date: Mon, 26 Jul 2004 20:56:47 -0500	[thread overview]
Message-ID: <87u0vui55s.fsf@trouble.defaultvalue.org> (raw)
In-Reply-To: <878ydajpc2.fsf@zip.com.au> (Kevin Ryde's message of "Sat, 24 Jul 2004 09:06:37 +1000")

Kevin Ryde <user42@zip.com.au> writes:

> Ah, a bit dodgy that.
>
> If you're hunting dodginess, it looks like make-s16vector may assume a
> short is 16-bits when converting the "fill" parameter from an SCM.  A
> system with a bigger short probably gets values silently truncated
> instead of provoking range errors.  Similarly u16, and s32 and u32
> with "int".

Yep, thanks, though I *think*, I've probably already fixed those.  I
something similar to this for each one:

SCM_DEFINE (scm_make_s16vector, "make-s16vector", 1, 1, 0,
            (SCM n, SCM fill),
	    "Create a newly allocated homogeneous numeric vector which can\n"
	    "hold @var{len} elements.  If @var{fill} is given, it is used to\n"
	    "initialize the elements, otherwise the contents of the vector\n"
	    "is unspecified.")
#define FUNC_NAME s_scm_make_s16vector
{
  SCM uvec;
  size_t count = scm_num2size (n, 1, s_scm_make_s16vector);
  uvec = make_uvec (1, FUNC_NAME, SCM_UVEC_S16, count);

  if (SCM_UNBNDP (fill))
    memset (SCM_UVEC_BASE (uvec), 0, count * sizeof (int_s16));
  else
  {
    int_s16 * p;
    int f = scm_num2int (fill, 2, FUNC_NAME);

#if SIZEOF_INT > 2
    SCM_ASSERT_RANGE (2, fill,
                      (f >= (int_s16) -32768) && (f <= (int_s16) 32767));
#endif
    
    p = (int_s16 *) SCM_UVEC_BASE (uvec);
    while (count-- > 0)
      *p++ = f;
  }
  return uvec;
}
#undef FUNC_NAME


-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


      reply	other threads:[~2004-07-27  1:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-04 23:51 make-regexp error memory leak Kevin Ryde
2004-07-07 17:41 ` Rob Browning
2004-07-08 23:57   ` Kevin Ryde
2004-07-09 18:03     ` Rob Browning
2004-07-10  0:05       ` Kevin Ryde
2004-07-11 18:37         ` Rob Browning
2004-07-23 23:06           ` Kevin Ryde
2004-07-27  1:56             ` Rob Browning [this message]

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=87u0vui55s.fsf@trouble.defaultvalue.org \
    --to=rlb@defaultvalue.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).