[Python-3000-checkins] r61307 - python/branches/py3k/Modules/_localemodule.c

martin.v.loewis python-3000-checkins at python.org
Sat Mar 8 11:54:32 CET 2008


Author: martin.v.loewis
Date: Sat Mar  8 11:54:31 2008
New Revision: 61307

Modified:
   python/branches/py3k/Modules/_localemodule.c
Log:
Properly size memory blocks in units of wchar_t.


Modified: python/branches/py3k/Modules/_localemodule.c
==============================================================================
--- python/branches/py3k/Modules/_localemodule.c	(original)
+++ python/branches/py3k/Modules/_localemodule.c	Sat Mar  8 11:54:31 2008
@@ -61,7 +61,7 @@
     if (needed < sizeof(smallbuf))
         dest = smallbuf;
     else {
-        dest = PyMem_Malloc(needed+1);
+        dest = PyMem_Malloc((needed+1)*sizeof(wchar_t));
         if (!dest)
             return PyErr_NoMemory();
     }
@@ -282,7 +282,7 @@
 #ifdef HAVE_USABLE_WCHAR_T
     s = s0;
 #else
-    s = PyMem_Malloc(n0+1);
+    s = PyMem_Malloc((n0+1)*sizeof(wchar_t));
     if (!s)
         return PyErr_NoMemory();
     for (i=0; i<=n0; i++)
@@ -291,7 +291,7 @@
 
     /* assume no change in size, first */
     n1 = wcslen(s) + 1;
-    buf = PyMem_Malloc(n1);
+    buf = PyMem_Malloc(n1*sizeof(wchar_t));
     if (!buf) {
         PyErr_NoMemory();
         goto exit;
@@ -299,7 +299,7 @@
     n2 = wcsxfrm(buf, s, n1);
     if (n2 >= n1) {
         /* more space needed */
-        buf = PyMem_Realloc(buf, n2+1);
+        buf = PyMem_Realloc(buf, (n2+1)*sizeof(wchar_t));
         if (!buf) {
             PyErr_NoMemory();
             goto exit;


More information about the Python-3000-checkins mailing list