diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-04-12 07:22:56 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-04-12 07:22:56 (GMT) |
commit | af3e8de580ba756e820171253a5b580318914b79 (patch) | |
tree | 3bb909464364789e6fc22a1c2921246488b9d68c /Modules | |
parent | e9e7452505ddf0ab68ed1f63aa6a19963137c2df (diff) | |
download | cpython-af3e8de580ba756e820171253a5b580318914b79.zip cpython-af3e8de580ba756e820171253a5b580318914b79.tar.gz cpython-af3e8de580ba756e820171253a5b580318914b79.tar.bz2 |
First stab at rationalizing the PyMem_ API. Mixing PyObject_xyz with
PyMem_{Del, DEL} doesn't work yet (compilation problems).
pyport.h: _PyMem_EXTRA is gone.
pmem.h: Repaired comments. PyMem_{Malloc, MALLOC} and
PyMem_{Realloc, REALLOC} now make the same x-platform guarantees when
asking for 0 bytes, and when passing a NULL pointer to the latter.
object.c: PyMem_{Malloc, Realloc} just call their macro versions
now, since the latter take care of the x-platform 0 and NULL stuff
by themselves now.
pypcre.c, grow_stack(): So sue me. On two lines, this called
PyMem_RESIZE to grow a "const" area. It's not legit to realloc a
const area, so the compiler warned given the new expansion of
PyMem_RESIZE. It would have gotten the same warning before if it
had used PyMem_Resize() instead; the older macro version, but not the
function version, silently cast away the constness. IMO that was a wrong
thing to do, and the docs say the macro versions of PyMem_xyz are
deprecated anyway. If somebody else is resizing const areas with the
macro spelling, they'll get a warning when they recompile now too.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/pypcre.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/pypcre.c b/Modules/pypcre.c index e0aa8d0..5f21005 100644 --- a/Modules/pypcre.c +++ b/Modules/pypcre.c @@ -3078,8 +3078,11 @@ static int grow_stack(match_data *md) else {md->length = 80;} } PyMem_RESIZE(md->offset_top, int, md->length); - PyMem_RESIZE(md->eptr, const uschar *, md->length); - PyMem_RESIZE(md->ecode, const uschar *, md->length); + /* Can't realloc a pointer-to-const; cast const away. */ + md->eptr = (const uschar **)PyMem_Realloc((void *)md->eptr, + sizeof(uschar *) * md->length); + md->ecode = (const uschar **)PyMem_Realloc((void *)md->ecode, + sizeof(uschar *) * md->length); PyMem_RESIZE(md->off_num, int, md->length); PyMem_RESIZE(md->r1, int, md->length); PyMem_RESIZE(md->r2, int, md->length); |