diff options
author | ZyX <kp-pav@yandex.ru> | 2016-04-18 15:55:51 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2016-06-24 16:53:26 +0300 |
commit | da15b5c1f3230b127ebdbe52d449d1ee8104b2ae (patch) | |
tree | c6b432e23f07e456826c9f7d99104fc1da2defcc /src/nvim/api/private/helpers.h | |
parent | 47a15d0256170e9ce33cda23d8f0b39451fa7129 (diff) | |
download | rneovim-da15b5c1f3230b127ebdbe52d449d1ee8104b2ae.tar.gz rneovim-da15b5c1f3230b127ebdbe52d449d1ee8104b2ae.tar.bz2 rneovim-da15b5c1f3230b127ebdbe52d449d1ee8104b2ae.zip |
api/helpers: Use typval_encode.h for vim_to_object
This ought to prevent stack overflow, but I do not see this actually working:
*lua* code crashes with stack overflow when trying to deserialize msgpack from
Neovim, Neovim is fine even if nesting level is increased 100x (though test
becomes very slow); not sure how recursive function may survive this. So it
looks like there are currently only two positive effects:
1. NULL lists are returned as empty (#4596).
2. Functional tests are slightly more fast. Very slightly. Checked for Release
build for test/functional/eval tests because benchmarking of debug mode is
not very useful.
Diffstat (limited to 'src/nvim/api/private/helpers.h')
-rw-r--r-- | src/nvim/api/private/helpers.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 731f186ecc..a946e35149 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -27,6 +27,10 @@ .type = kObjectTypeInteger, \ .data.integer = i }) +#define FLOATING_OBJ(f) ((Object) { \ + .type = kObjectTypeFloat, \ + .data.floating = f }) + #define STRING_OBJ(s) ((Object) { \ .type = kObjectTypeString, \ .data.string = s }) @@ -61,6 +65,13 @@ #define STATIC_CSTR_AS_STRING(s) ((String) {.data = s, .size = sizeof(s) - 1}) +/// Create a new String instance, putting data in allocated memory +/// +/// @param[in] s String to work with. Must be a string literal. +#define STATIC_CSTR_TO_STRING(s) ((String){ \ + .data = xmemdupz(s, sizeof(s) - 1), \ + .size = sizeof(s) - 1 }) + // Helpers used by the generated msgpack-rpc api wrappers #define api_init_boolean #define api_init_integer |