added container_of macro

This commit is contained in:
Fabrice Bellard
2023-12-22 11:03:44 +01:00
parent 1692f2a7a3
commit c3599515c8
3 changed files with 5 additions and 3 deletions

View File

@@ -4064,7 +4064,7 @@ void JS_FreeCString(JSContext *ctx, const char *ptr)
if (!ptr)
return;
/* purposely removing constness */
p = (JSString *)(void *)(ptr - offsetof(JSString, u));
p = container_of(ptr, JSString, u);
JS_FreeValue(ctx, JS_MKPTR(JS_TAG_STRING, p));
}