changed moo_shallowcopy() to stop copying a process object or an object with trailers

This commit is contained in:
hyunghwan.chung 2019-09-20 09:27:24 +00:00
parent e0c116ecd4
commit 97f264398d

View File

@ -1120,9 +1120,15 @@ moo_oop_t moo_shallowcopy (moo_t* moo, moo_oop_t oop)
moo_oop_t z; moo_oop_t z;
moo_oow_t total_bytes; moo_oow_t total_bytes;
total_bytes = MOO_SIZEOF(moo_obj_t) + moo_getobjpayloadbytes(moo, oop); if (MOO_OBJ_GET_FLAGS_TRAILER(oop) || MOO_OBJ_GET_FLAGS_PROC(oop))
{
/* TOOD: should i disallow this or return without copying? */
moo_seterrbfmt (moo, MOO_EPERM, "not allowed to copy process or object with trailer");
return MOO_NULL;
}
/* TODO: exclude trailer and hash space? exclde hash space at least? */ /* TODO: exclude trailer and hash space? exclde hash space at least? */
total_bytes = MOO_SIZEOF(moo_obj_t) + moo_getobjpayloadbytes(moo, oop);
moo_pushvolat (moo, &oop); moo_pushvolat (moo, &oop);
z = (moo_oop_t)moo_allocbytes(moo, total_bytes); z = (moo_oop_t)moo_allocbytes(moo, total_bytes);