diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-12-11 10:04:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-12-11 10:04:44 +0300 |
commit | 576d385ddb581190d21febfa724086797c47492a (patch) | |
tree | 841744bda1ec26fdd4a9af7113b6fb746a5d53fd /source/blender/python/intern | |
parent | f52d60a21d4d3551190305549dbb2a647a1ae0c9 (diff) |
PyAPI: add utility functions get the size from an evaluated string
Allows including null bytes in the resulting string.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index a69ce068aec..2b9556e998a 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -618,8 +618,12 @@ bool BPY_execute_string_as_number( /** * \return success */ -bool BPY_execute_string_as_string( - bContext *C, const char *imports[], const char *expr, const bool verbose, char **r_value) +bool BPY_execute_string_as_string_and_size(bContext *C, + const char *imports[], + const char *expr, + const bool verbose, + char **r_value, + size_t *r_value_size) { BLI_assert(r_value && expr); PyGILState_STATE gilstate; @@ -632,7 +636,7 @@ bool BPY_execute_string_as_string( bpy_context_set(C, &gilstate); - ok = PyC_RunString_AsString(imports, expr, "<expr as str>", r_value); + ok = PyC_RunString_AsStringAndSize(imports, expr, "<expr as str>", r_value, r_value_size); if (ok == false) { if (verbose) { @@ -648,6 +652,14 @@ bool BPY_execute_string_as_string( return ok; } +bool BPY_execute_string_as_string( + bContext *C, const char *imports[], const char *expr, const bool verbose, char **r_value) +{ + size_t value_dummy_size; + return BPY_execute_string_as_string_and_size( + C, imports, expr, verbose, r_value, &value_dummy_size); +} + /** * Support both int and pointers. * |