| 77 | } |
| 78 | |
| 79 | void ckpt_json_delete(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
| 80 | { |
| 81 | // json_array_element/json_object_element return borrowed pointers into a |
| 82 | // parent tree with the same struct JSON* type as an owned root, so this is |
| 83 | // the one place that can tell the two apart: only a root json_new adopted |
| 84 | // is in the heap. Deleting a borrowed element used to corrupt the |
| 85 | // allocator; now it fails the script where the mistake was made. |
| 86 | const ScriptArgs args(Parser, Param, NumArgs, "json_delete"); |
| 87 | if (!ScriptHeap::get().release(tree(args, 0))) { |
| 88 | args.fail("argument 1 is not a json_new root"); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | void ckpt_json_is_valid(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
| 93 | { |