/* ---- Standalone functions ---- */
#define MAXCACHE 100
+static PyObject *cache = NULL;
static PyObject *
cache_struct(PyObject *fmt)
{
- static PyObject *cache = NULL;
PyObject * s_object;
if (cache == NULL) {
return s_object;
}
+PyDoc_STRVAR(clearcache_doc,
+"Clear the internal cache.");
+
+static PyObject *
+clearcache(PyObject *self)
+{
+ if (cache != NULL)
+ PyDict_Clear(cache);
+ Py_RETURN_NONE;
+}
+
PyDoc_STRVAR(calcsize_doc,
"Return size of C struct described by format string fmt.");
}
static struct PyMethodDef module_functions[] = {
+ {"_clearcache", (PyCFunction)clearcache, METH_NOARGS, clearcache_doc},
{"calcsize", calcsize, METH_O, calcsize_doc},
{"pack", pack, METH_VARARGS, pack_doc},
{"pack_into", pack_into, METH_VARARGS, pack_into_doc},