• Hmm, for ESP32 I would prefer simple malloc solution.
    I checked this in a first simple test(see code at the end) and in a first test it works fine.
    But doing board specific changes in jsvar.c is not my favourite solution.

    Anyway I'm still confused about the impact of 32bits.
    In internals link and in source of jsvar I only find 12 byte or 16 byte.
    There is a note JsVars for 32 bit refs are similar, but what does this mean ?
    Same for build_platform_config.py, which checks for less than 1024 only.
    In which case would we need 24 bytes instead of 16 ?

    BTW is there a limit for variables ? I can see ESPRUINOWIFI has 7135.
    What would happen with 10000 or 50000 jsvars ?
    It's a kind of theoretical question, but having 4MB heap, .....

    #ifdef RESIZABLE_JSVARS JsVar
    **jsVarBlocks = 0;
    unsigned int jsVarsSize = 0;
    #define JSVAR_BLOCK_SIZE 4096
    #define JSVAR_BLOCK_SHIFT 12
    #else
    #ifdef ESP32
    JsVar *jsVars = NULL;
    unsigned int jsVarsSize = 0;
    #else
    JsVar jsVars[JSVAR_CACHE_SIZE];
    unsigned int jsVarsSize = JSVAR_CACHE_SIZE;
    #endif
    #endif

    and this:

    void jsvInit() {
    #ifdef RESIZABLE_JSVARS
    jsVarsSize = JSVAR_BLOCK_SIZE;
    jsVarBlocks = malloc(sizeof(JsVar*)); // just 1
    jsVarBlocks[0] = malloc(sizeof(JsVar) * JSVAR_BLOCK_SIZE);
    #endif
    #ifdef ESP32
    jsVars = (JsVar *)malloc(33600);
    jsVarsSize = 2100;
    #endif
    jsVarFirstEmpty = jsvInitJsVars(1/first/, jsVarsSize);
    jsvSoftInit();
    }

About

Avatar for JumJum @JumJum started