Re: regexec() and OS/X

2006-06-01 Thread Paul Eggert
James Gallagher <[EMAIL PROTECTED]> writes: > I've found what appears to be a stack corruption when using regexec() > on a PPC Mac running OS/X 10.3.9. I was wondering if this is a known > problem? I don't know of any such problem. Looks like you may have to debug it. > After the call to regexe

regexec() and OS/X

2006-06-01 Thread James Gallagher
I've found what appears to be a stack corruption when using regexec() on a PPC Mac running OS/X 10.3.9. I was wondering if this is a known problem? Or maybe just an obvious goof on my part??? I am calling regexec() using: int result = regexec(&d_preg, ss.substr(pos, len).c_str(), 1, pmat

Re: realloc buggy?

2006-06-01 Thread Paul Eggert
>> With glibc, if p is not null, realloc (p, 0) always returns NULL. > > And free's p, presumably? Yes. > The glibc behaviour here seems like something we shouldn't encourage > IMHO. Ah, then we probably shouldn't document it either. (:-)

Re: strfile: new module

2006-06-01 Thread Simon Josefsson
Here's the updated module. Note the slight documentation change since my e-mail to Bruno. Index: lib/read-file.c === RCS file: lib/read-file.c diff -N lib/read-file.c --- /dev/null 1 Jan 1970 00:00:00 - +++ lib/read-file.c

Re: strfile: new module

2006-06-01 Thread Simon Josefsson
Bruno Haible <[EMAIL PROTECTED]> writes: > Simon Josefsson wrote: >> Here's the module. Only lighted tested, mostly to get feedback on the >> approach, but if you agree with it, detailed review would be useful. > > Looks already quite good. Only minor nits: > >> +/* Read a STREAM and return a new

Re: strfile: new module

2006-06-01 Thread Bruno Haible
Simon Josefsson wrote: > Here's the module. Only lighted tested, mostly to get feedback on the > approach, but if you agree with it, detailed review would be useful. Looks already quite good. Only minor nits: > +/* Read a STREAM and return a newly allocated string with the content, > + and set

Re: realloc buggy?

2006-06-01 Thread Simon Josefsson
Paul Eggert <[EMAIL PROTECTED]> writes: > Simon Josefsson <[EMAIL PROTECTED]> writes: > >> What about this instead? > > Unfortunately that is buggy too, if the goal is to emulate glibc. > With glibc, if p is not null, realloc (p, 0) always returns NULL. And free's p, presumably? > Conversely, re

Re: strfile: new module

2006-06-01 Thread Simon Josefsson
Ralf Wildenhues <[EMAIL PROTECTED]> writes: > * Paul Eggert wrote on Thu, Jun 01, 2006 at 10:20:58AM CEST: >> Simon Josefsson <[EMAIL PROTECTED]> writes: >> >> > What about realloc (NULL, ...)? >> >> In practice that is as portable as free (NULL). They were >> standardized at the same time. > >

Re: realloc buggy?

2006-06-01 Thread Paul Eggert
Simon Josefsson <[EMAIL PROTECTED]> writes: > What about this instead? Unfortunately that is buggy too, if the goal is to emulate glibc. With glibc, if p is not null, realloc (p, 0) always returns NULL. Conversely, realloc (NULL, 0) is equivalent to malloc (0) and typically returns non-NULL. It

Re: strfile: new module

2006-06-01 Thread Ralf Wildenhues
* Paul Eggert wrote on Thu, Jun 01, 2006 at 10:20:58AM CEST: > Simon Josefsson <[EMAIL PROTECTED]> writes: > > > What about realloc (NULL, ...)? > > In practice that is as portable as free (NULL). They were > standardized at the same time. Well, with the difference being here that realloc, simi

Re: strfile: new module

2006-06-01 Thread Paul Eggert
Simon Josefsson <[EMAIL PROTECTED]> writes: > What about realloc (NULL, ...)? In practice that is as portable as free (NULL). They were standardized at the same time.

realloc buggy?

2006-06-01 Thread Simon Josefsson
For read-file, I looked at realloc, and can't help but feel it is buggy. Here is the function: void * rpl_realloc (void *p, size_t n) { if (n == 0) { n = 1; /* In theory realloc might fail, so don't rely on it to free. */ free (p); p = NULL; } if (p == NULL)

Re: strfile: new module

2006-06-01 Thread Simon Josefsson
Paul Eggert <[EMAIL PROTECTED]> writes: > Simon Josefsson <[EMAIL PROTECTED]> writes: > >> I think we should be able to assume free (NULL) works though > > Yes. To my knowledge the last major system for which the 'free' > module was needed was SunOS 4.1.4 aka Solaris 1.1.2. Sun stopped > patchin