diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-16 23:16:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-16 23:16:16 (GMT) |
commit | 168e117e0a8825bc3ae0c08f0b08a33ac351a14f (patch) | |
tree | 8f9e0067a2d14a362844f891815791d9d41cfb79 /Modules/main.c | |
parent | 0a1b8cba90d467e85be87cd8b10b4d31caa8765a (diff) | |
download | cpython-168e117e0a8825bc3ae0c08f0b08a33ac351a14f.zip cpython-168e117e0a8825bc3ae0c08f0b08a33ac351a14f.tar.gz cpython-168e117e0a8825bc3ae0c08f0b08a33ac351a14f.tar.bz2 |
Add an optional size argument to _Py_char2wchar()
_Py_char2wchar() callers usually need the result size in characters. Since it's
trivial to compute it in _Py_char2wchar() (O(1) whereas wcslen() is O(n)), add
an option to get it.
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/main.c b/Modules/main.c index bbf695f..0c38fac 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -486,10 +486,12 @@ Py_Main(int argc, wchar_t **argv) /* Use utf-8 on Mac OS X */ unicode = PyUnicode_FromString(p); #else - wchar_t *wchar = _Py_char2wchar(p); + wchar_t *wchar; + size_t len; + wchar = _Py_char2wchar(p, &len); if (wchar == NULL) continue; - unicode = PyUnicode_FromWideChar(wchar, wcslen(wchar)); + unicode = PyUnicode_FromWideChar(wchar, len); PyMem_Free(wchar); #endif if (unicode == NULL) |