diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-02-21 11:07:37 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-02-21 11:07:37 (GMT) |
commit | 957d07a159b2ec68a1aec9ad8cb1ffbd3c43ba63 (patch) | |
tree | 6b7c28cfb295aa8a014433c90ac6fa5fc190d0ad | |
parent | 42b9bc7a7df72a3f54f6d0419aa9ec864031acac (diff) | |
download | cpython-957d07a159b2ec68a1aec9ad8cb1ffbd3c43ba63.zip cpython-957d07a159b2ec68a1aec9ad8cb1ffbd3c43ba63.tar.gz cpython-957d07a159b2ec68a1aec9ad8cb1ffbd3c43ba63.tar.bz2 |
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
-rw-r--r-- | Mac/Modules/macosmodule.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Mac/Modules/macosmodule.c b/Mac/Modules/macosmodule.c index 586d675..ece75c9 100644 --- a/Mac/Modules/macosmodule.c +++ b/Mac/Modules/macosmodule.c @@ -685,6 +685,46 @@ MacOS_openrf(PyObject *self, PyObject *args) return (PyObject *)fp; } +static char FreeMem_doc[] = "Return the total amount of free space in the heap"; + +static PyObject * +MacOS_FreeMem(PyObject *self, PyObject *args) +{ + long rv; + + if (!PyArg_ParseTuple(args, "")) + return NULL; + rv = FreeMem(); + return Py_BuildValue("l", rv); +} + +static char MaxBlock_doc[] = "Return the largest contiguous block of free space in the heap"; + +static PyObject * +MacOS_MaxBlock(PyObject *self, PyObject *args) +{ + long rv; + + if (!PyArg_ParseTuple(args, "")) + return NULL; + rv = MaxBlock(); + return Py_BuildValue("l", rv); +} + +static char CompactMem_doc[] = "(wanted size)->actual largest block after compacting"; + +static PyObject * +MacOS_CompactMem(PyObject *self, PyObject *args) +{ + long value; + long rv; + + if (!PyArg_ParseTuple(args, "l", &value)) + return NULL; + rv = CompactMem(value); + return Py_BuildValue("l", rv); +} + static PyMethodDef MacOS_Methods[] = { {"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1, accepthle_doc}, {"GetCreatorAndType", MacOS_GetCreatorAndType, 1, getcrtp_doc}, @@ -702,6 +742,9 @@ static PyMethodDef MacOS_Methods[] = { {"DebugStr", MacOS_DebugStr, 1, DebugStr_doc}, {"GetTicks", MacOS_GetTicks, 1, GetTicks_doc}, {"SysBeep", MacOS_SysBeep, 1, SysBeep_doc}, + {"FreeMem", MacOS_FreeMem, 1, FreeMem_doc}, + {"MaxBlock", MacOS_MaxBlock, 1, MaxBlock_doc}, + {"CompactMem", MacOS_CompactMem, 1, CompactMem_doc}, {NULL, NULL} /* Sentinel */ }; |