summaryrefslogtreecommitdiffstats
path: root/Include/pymem.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove MALLOC_ZERO_RETURNS_NULL.Martin v. Löwis2002-11-231-9/+4
|
* Excise DL_EXPORT from Include.Mark Hammond2002-08-121-3/+3
| | | | Thanks to Skip Montanaro and Kalle Svensson for the patches.
* Moving pymalloc along.Tim Peters2002-04-281-37/+42
| | | | | | | | | | As threatened, PyMem_{Free, FREE} also invoke the object deallocator now when pymalloc is enabled (well, it does when pymalloc isn't enabled too, but in that case "the object deallocator" is plain free()). This is maximally backward-compatible, but it leaves a bitter aftertaste. Also massive reworking of comments.
* Moving pymalloc along.Tim Peters2002-04-221-13/+9
| | | | | | | | | | | | | | | | | | + Redirect PyMem_{Del, DEL} to the object allocator's free() when pymalloc is enabled. Needed so old extensions can continue to mix PyObject_New with PyMem_DEL. + This implies that pgen needs to be able to see the PyObject_XYZ declarations too. pgenheaders.h now includes Python.h. An implication is that I expect obmalloc.o needs to get linked into pgen on non-Windows boxes. + When PYMALLOC_DEBUG is defined, *all* Py memory API functions now funnel through the debug allocator wrapper around pymalloc. This is the default in a debug build. + That caused compile.c to fail: it indirectly mixed PyMem_Malloc with raw platform free() in one place. This is verbotten.
* First stab at rationalizing the PyMem_ API. Mixing PyObject_xyz withTim Peters2002-04-121-40/+55
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove PyMalloc_* symbols. PyObject_Malloc now uses pymalloc ifNeil Schemenauer2002-04-121-30/+0
| | | | it's enabled.
* New PYMALLOC_DEBUG function void _PyMalloc_DebugDumpStats(void).Tim Peters2002-04-011-0/+1
| | | | | | | | | | | | | This displays stats about the # of arenas, pools, blocks and bytes, to stderr, both used and reserved but unused. CAUTION: Because PYMALLOC_DEBUG is on, the debug malloc routine adds 16 bytes to each request. This makes each block appear two size classes higher than it would be if PYMALLOC_DEBUG weren't on. So far, playing with this confirms the obvious: there's a lot of activity in the "small dict" size class, but nothing in the core makes any use of the 8-byte or 16-byte classes.
* PYMALLOC_DEBUG routines: The "check API family" gimmick was going nowhereTim Peters2002-03-281-6/+6
| | | | | fast, and just cluttered the code. Get rid of it for now. If a compelling case can be made for it, easy to restore it later.
* Give Python a debug-mode pymalloc, much as sketched on Python-Dev.Tim Peters2002-03-231-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug allocator. This can be done independent of build type (release or debug). A debug build automatically defines PYMALLOC_DEBUG when pymalloc is enabled. It's a detected error to define PYMALLOC_DEBUG when pymalloc isn't enabled. Two debugging entry points defined only under PYMALLOC_DEBUG: + _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb) to sanity-check a memory block obtained from pymalloc. It sprays info to stderr (see next) and dies via Py_FatalError if the block is detectably damaged. + _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info about a debug memory block to stderr. A tiny start at implementing "API family" checks isn't good for anything yet. _PyMalloc_DebugRealloc() has been optimized to do little when the new size is <= old size. However, if the new size is larger, it really can't call the underlying realloc() routine without either violating its contract, or knowing something non-trivial about how the underlying realloc() works. A memcpy is always done in this case. This was a disaster for (and only) one of the std tests: test_bufio creates single text file lines up to a million characters long. On Windows, fileobject.c's get_line() uses the horridly funky getline_via_fgets(), which keeps growing and growing a string object hoping to find a newline. It grew the string object 1000 bytes each time, so for a million-character string it took approximately forever (I gave up after a few minutes). So, also: fileobject.c, getline_via_fgets(): When a single line is outrageously long, grow the string object at a mildly exponential rate, instead of just 1000 bytes at a time. That's enough so that a debug-build test_bufio finishes in about 5 seconds on my Win98SE box. I'm curious to try this on Win2K, because it has very different memory behavior than Win9X, and test_bufio always took a factor of 10 longer to complete on Win2K. It *could* be that the endless reallocs were simply killing it on Win2K even in the release build.
* Arrange to export the _PyMalloc_{Malloc, Realloc, Free} entry points. OnTim Peters2002-03-201-3/+3
| | | | | | | | | | | | | Windows some modules are considered (by me, and I don't care what anyone else thinks about this <wink>) to be part of "the core" despite that they happen to be compiled into separate DLLs (the "to DLL or not to DLL?" question on Windows is nearly arbitrary). Making the pymalloc entry points available to them allows the Windows build to complete without incident when WITH_PYMALLOC is #define'd. Note that this isn't unprecedented. Other "private API" functions we export include _PySequence_IterSearch, _PyEval_SliceIndex, _PyCodec_Lookup, _Py_ZeroStruct, _Py_TrueStruct, _PyLong_New and _PyModule_Clear.
* Drop the PyCore_* memory API.Neil Schemenauer2002-03-181-25/+26
|
* Simpilify PyCore_* macros by assuming the function prototypes forNeil Schemenauer2002-03-181-68/+4
| | | | malloc() and free() don't change.
* Whether platform malloc(0) returns NULL has nothing to do with whetherTim Peters2002-03-021-7/+12
| | | | | | | | | | | platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can be correctly undefined yet realloc(p, 0) can return NULL anyway. Prevent realloc(p, 0) doing free(p) and returning NULL via a different hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL entirely. Bugfix candidate.
* Repair more now-obsolete references to config.h.Tim Peters2001-07-261-1/+1
|
* REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum2000-09-011-9/+0
| | | | This should match the situation in the 1.6b1 tree.
* Fix a typo in the PyMem_Resize macro, found by Andrew KuchlingVladimir Marangozov2000-08-131-1/+1
|
* patch from Vladimir (move Py_Mem* interface to Include/pymem.h)Peter Schneider-Kamp2000-07-311-0/+179