You are reading a single comment by @!evil and its replies. Click here to read the full conversation.
  • Hi,

    I was wondering what the recommended approach to memory overflow is. Most of jsvar.c check for overflow and behave accordingly, while other code assume no overflow, e.g. _jswrap_interface_setTimeoutOrInterval. Then there is jsvObjectSetChildAndUnLock which doesn't unlock the child in case of overflow, while others like jsvArrayPushAndUnLock do.

    I tried to use the following defines for perfect overflow coverage in my library

    ﹟define INIT(n) JsVar* _lock_array[n]; int _lock_index = 0
    ﹟define END(i) _end(i, _lock_array, _lock_index)
    ﹟define NEW(a) ({ JsVar* var = a; if (!var) return END(0); _lock_array[_lock_index++] = var; var; })
    ﹟define TMP(a) ({ JsVar* var = a; if (!var) return END(0); var; })
    ﹟define GRD(a) if (!(a)) return END(0);
    JsVar* _end(int end_index, JsVar** array, int index) {
      while (index != end_index) jsvUnLock(array[--index]);
      return 0;

    but I'm uncertain if its worth the trouble. What if I won't check for overflow, like _jswrap_interface_setTimeoutOrInterval, would it lead to unexpected behavior in case of overflow instead of noisy "segfault"?


Avatar for !evil @!evil started