[Python-checkins] CVS: python/dist/src/PC winreg.c,1.1,1.2

Guido van Rossum python-dev@python.org
Wed, 3 May 2000 19:45:09 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/PC
In directory eric:/projects/python/develop/guido/clean/PC

Modified Files:
	winreg.c 
Log Message:
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.)



Index: winreg.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/PC/winreg.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** winreg.c	2000/03/28 20:37:15	1.1
--- winreg.c	2000/05/03 23:44:37	1.2
***************
*** 371,375 ****
  	if (obkey->hkey)
  		RegCloseKey((HKEY)obkey->hkey);
! 	PyMem_DEL(ob);
  }
  
--- 371,375 ----
  	if (obkey->hkey)
  		RegCloseKey((HKEY)obkey->hkey);
! 	PyObject_DEL(ob);
  }
  
***************
*** 605,614 ****
  PyHKEY_FromHKEY(HKEY h)
  {
! 	PyHKEYObject *op = (PyHKEYObject *) malloc(sizeof(PyHKEYObject));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	op->ob_type = &PyHKEY_Type;
  	op->hkey = h;
- 	_Py_NewReference((PyObject *)op);
  	return (PyObject *)op;
  }
--- 605,616 ----
  PyHKEY_FromHKEY(HKEY h)
  {
! 	PyHKEYObject *op;
! 
! 	/* PyObject_New is inlined */
! 	op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject));
  	if (op == NULL)
  		return PyErr_NoMemory();
! 	PyObject_INIT(op, &PyHKEY_Type);
  	op->hkey = h;
  	return (PyObject *)op;
  }
***************
*** 1349,1353 ****
  	rc = RegSetValueEx(hKey, valueName, 0, typ, data, len);
  	Py_END_ALLOW_THREADS
! 	PyMem_Free(data);
  	if (rc != ERROR_SUCCESS)
  		return PyErr_SetFromWindowsErrWithFunction(rc,
--- 1351,1355 ----
  	rc = RegSetValueEx(hKey, valueName, 0, typ, data, len);
  	Py_END_ALLOW_THREADS
! 	PyMem_DEL(data);
  	if (rc != ERROR_SUCCESS)
  		return PyErr_SetFromWindowsErrWithFunction(rc,