Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
diff --git a/PC/winreg.c b/PC/winreg.c
index 3dccc3d..bba9bc2 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -370,7 +370,7 @@
 	PyHKEYObject *obkey = (PyHKEYObject *)ob;
 	if (obkey->hkey)
 		RegCloseKey((HKEY)obkey->hkey);
-	PyMem_DEL(ob);
+	PyObject_DEL(ob);
 }
 
 static int
@@ -604,12 +604,14 @@
 PyObject *
 PyHKEY_FromHKEY(HKEY h)
 {
-	PyHKEYObject *op = (PyHKEYObject *) malloc(sizeof(PyHKEYObject));
+	PyHKEYObject *op;
+
+	/* PyObject_New is inlined */
+	op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject));
 	if (op == NULL)
 		return PyErr_NoMemory();
-	op->ob_type = &PyHKEY_Type;
+	PyObject_INIT(op, &PyHKEY_Type);
 	op->hkey = h;
-	_Py_NewReference((PyObject *)op);
 	return (PyObject *)op;
 }
 
@@ -1348,7 +1350,7 @@
 	Py_BEGIN_ALLOW_THREADS
 	rc = RegSetValueEx(hKey, valueName, 0, typ, data, len);
 	Py_END_ALLOW_THREADS
-	PyMem_Free(data);
+	PyMem_DEL(data);
 	if (rc != ERROR_SUCCESS)
 		return PyErr_SetFromWindowsErrWithFunction(rc,
 							   "RegSetValueEx");