[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make-regexp error memory leak
From: |
Rob Browning |
Subject: |
Re: make-regexp error memory leak |
Date: |
Mon, 26 Jul 2004 20:56:47 -0500 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Kevin Ryde <address@hidden> 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