PjHandle¶
-
class PjHandle¶
RAII handle for a rizin PJ (JSON builder).
Owns a pj_new() alloc, the destructor calls pj_free() on early return paths before the PJ is drained. drain() releases ownership (pj_drain frees the PJ and returns its buffer), so the destructor is a no-op after drain.
move used, as copying would alias the PJ and do double free.
{ PjHandle pj; if (!pj) { return; } pj_o(pj.get()); pj_ks(pj.get(), "name", "value"); pj_end(pj.get()); char *json = pj.drain(); // caller frees json }