[pypy-commit] pypy default: add track_allocation to utf82wcharp

mattip pypy.commits at gmail.com
Wed Feb 20 03:32:23 EST 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: 
Changeset: r96107:ad61d87e47a5
Date: 2019-02-20 10:11 +0200
http://bitbucket.org/pypy/pypy/changeset/ad61d87e47a5/

Log:	add track_allocation to utf82wcharp

diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1052,16 +1052,20 @@
         i += 1
     return s.build(), i
 
-def utf82wcharp(utf8, utf8len):
+def utf82wcharp(utf8, utf8len, track_allocation=True):
     from rpython.rlib import rutf8
 
-    w = lltype.malloc(CWCHARP.TO, utf8len + 1, flavor='raw')
+    if track_allocation:
+        w = lltype.malloc(CWCHARP.TO, utf8len + 1, flavor='raw', track_allocation=True)
+    else:
+        w = lltype.malloc(CWCHARP.TO, utf8len + 1, flavor='raw', track_allocation=False)
     index = 0
     for ch in rutf8.Utf8StringIterator(utf8):
         w[index] = unichr(ch)
         index += 1
     w[index] = unichr(0)
     return w
+utf82charp._annenforceargs_ = [str, int, bool]
 
 # char**
 CCHARPP = lltype.Ptr(lltype.Array(CCHARP, hints={'nolength': True}))


More information about the pypy-commit mailing list