diff --git a/lib/modules/Object.pmod b/lib/modules/Object.pmod index 5acdfa207129706cf518ed0e93e380ff2fbc2547..8511a9f3fe3a364ccf0219fccd43aff23bb72a1a 100644 --- a/lib/modules/Object.pmod +++ b/lib/modules/Object.pmod @@ -11,3 +11,5 @@ constant DESTRUCT_CLEANUP = __builtin.DESTRUCT_CLEANUP; //! @note //! @[Object.DESTRUCT_EXPLICIT] is @expr{0@} and //! @[Object.DESTRUCT_CLEANUP] is @expr{1@} for compatibility. + +constant secure = __builtin.object_secure; diff --git a/src/builtin.cmod b/src/builtin.cmod index 6f47de33de00e13151f6f8f8f66a3d79a47da00d..34877456449e5c784955823977d5d225452939b2 100644 --- a/src/builtin.cmod +++ b/src/builtin.cmod @@ -1336,7 +1336,7 @@ PIKEFUN mapping(1:2) mkmapping(array(1=mixed) ind, array(2=mixed) val) RETURN mkmapping(ind, val); } -/*! @decl void secure(string str) +/*! @decl string secure(string str) *! @belongs String *! *! Marks the string as secure, which will clear the memory area @@ -1350,6 +1350,20 @@ PIKEFUN string string_secure(string str) REF_RETURN str; } +/*! @decl object secure(object str) + *! @belongs Object + *! + *! Marks the object as secure, which will clear the memory area + *! before freeing the object. + */ +PIKEFUN object object_secure(object obj) + optflags OPT_SIDE_EFFECT; + rawtype tFunc(tSetvar(0, tObj), tVar(0)); +{ + obj->flags |= OBJECT_CLEAR_ON_EXIT; + REF_RETURN obj; +} + /*! @decl int count(string haystack, string needle) *! @belongs String *!