diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c b/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c new file mode 100644 index 000000000..8916577a4 --- /dev/null +++ b/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c @@ -0,0 +1,52 @@ +/* + * Misc support functions + */ + +#include "duk_internal.h" + +DUK_INTERNAL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop) { + duk_uint_t sanity; + + DUK_ASSERT(thr != NULL); + + /* False if the object is NULL or the prototype 'p' is NULL. + * In particular, false if both are NULL (don't compare equal). + */ + if (h == NULL || p == NULL) { + return 0; + } + + sanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY; + do { + if (h == p) { + return 1; + } + + if (sanity-- == 0) { + if (ignore_loop) { + break; + } else { + DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT); + } + } + h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); + } while (h); + + return 0; +} + +DUK_INTERNAL void duk_hobject_set_prototype_updref(duk_hthread *thr, duk_hobject *h, duk_hobject *p) { +#ifdef DUK_USE_REFERENCE_COUNTING + duk_hobject *tmp; + + DUK_ASSERT(h); + tmp = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h); + DUK_HOBJECT_SET_PROTOTYPE(thr->heap, h, p); + DUK_HOBJECT_INCREF_ALLOWNULL(thr, p); /* avoid problems if p == h->prototype */ + DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); +#else + DUK_ASSERT(h); + DUK_UNREF(thr); + DUK_HOBJECT_SET_PROTOTYPE(thr->heap, h, p); +#endif +} |