MCPcopy Create free account
hub / github.com/bytecodealliance/ComponentizeJS / GetMemBuffer

Function GetMemBuffer

embedding/embedding.cpp:510–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508void *LAST_SBRK = nullptr;
509JS::PersistentRootedObject AB;
510static bool GetMemBuffer(JSContext *cx, unsigned argc, JS::Value *vp) {
511 if (sbrk(0) != LAST_SBRK) {
512 LAST_SBRK = sbrk(0);
513#ifdef DEBUG
514 void *base = (void *)64;
515#else
516 void *base = 0;
517#endif
518 JS::RootedObject mem_buffer(cx, JS::NewArrayBufferWithUserOwnedContents(
519 cx, (size_t)LAST_SBRK, base));
520 AB.set(mem_buffer);
521 }
522 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
523 args.rval().setObject(*AB);
524 return true;
525}
526
527bool install(api::Engine *engine) {
528 Runtime.engine = engine;

Callers

nothing calls this directly

Calls 1

setMethod · 0.80

Tested by

no test coverage detected