772618ef89
lua-cjson decodes straight onto the Lua stack, so a response costs its text plus the table it becomes rather than a document in between, and it brings the encode half that a C tokenizer would have left to write here. It is a module rather than a global: a global namespace is a contract a firmware implements, and nothing about this needs a provider. Registering into package.preload also puts it ahead of the SD-card searcher, so an implementation cannot be shadowed, and an app that never requires it never pays for the module. Depth is capped at 32 through the module's own knobs rather than by patching the vendored source. Decoding recurses on the C stack and upstream defaults to 1000, which assumes a server rather than a FreeRTOS task.
33 lines
769 B
C
33 lines
769 B
C
/* Lua CJSON floating point conversion routines */
|
|
|
|
/* Buffer required to store the largest string representation of a double.
|
|
*
|
|
* Longest double printed with %.14g is 21 characters long:
|
|
* -1.7976931348623e+308 */
|
|
# define FPCONV_G_FMT_BUFSIZE 32
|
|
|
|
#ifdef USE_INTERNAL_FPCONV
|
|
#ifdef MULTIPLE_THREADS
|
|
#include "dtoa_config.h"
|
|
#include <unistd.h>
|
|
static inline void fpconv_init()
|
|
{
|
|
// Add one to try and avoid core id multiplier alignment
|
|
set_max_dtoa_threads((sysconf(_SC_NPROCESSORS_CONF) + 1) * 3);
|
|
}
|
|
#else
|
|
static inline void fpconv_init()
|
|
{
|
|
/* Do nothing - not required */
|
|
}
|
|
#endif
|
|
#else
|
|
extern void fpconv_init(void);
|
|
#endif
|
|
|
|
extern int fpconv_g_fmt(char*, double, int);
|
|
extern double fpconv_strtod(const char*, char**);
|
|
|
|
/* vi:ai et sw=4 ts=4:
|
|
*/
|