#include "runtime_internal.h"

#define INLINE inline __attribute__((weak)) __attribute__((always_inline)) __attribute__((used))

extern "C" {

INLINE void call_destructor(void *user_context, void (*fn)(void *user_context, void *object), void **object) {
    // Call the function
    if (*object) {
        fn(user_context, *object);
    }
    *object = NULL;
}

}

#include "runtime_internal.h"

#define INLINE inline __attribute__((weak)) __attribute__((always_inline)) __attribute__((used))

extern "C" {

INLINE void call_destructor(void *user_context, void (*fn)(void *user_context, void *object), void **object) {
    void *o = *object;
    *object = NULL;
    // Call the function
    if (o) {
        fn(user_context, o);
    }
}

}

Set stack slot to null before calling destructor
Set stack slot to null before calling destructor

Just in case the destructor block gets branched to somehow.


Former-commit-id: 9ff4f3dc9d6b8de56f5a54f33f2c3eb6f989ec51