On Wed, 13 Jan 2010, Szak�ts Viktor wrote:

Hi,

> Is there a safe way to clear to content of a variable in Harbour?

Indirectly by functions using hb_itemGetWriteCL() on parameters passed
by reference. You can find few functions in HBRTL.

> --- server.prg
> ? "Please enter password:"
> ACCEPT TO pw
> <process pw>
> pw := NIL
> <server loop>
> ---
> I want that the content of 'pw' variable be surely 
> cleared from memory.
> Is this currently possible? and how?

You can create dedicated function for such job:

   HB_FUNC( HB_SETSPACE )
   {
      PHB_ITEM pString = hb_param( 1, HB_IT_STRING );

      if( pString )
      {
         ULONG ulSize;
         char * buffer;

         /* clear RETURN value before calling hb_itemGetWriteCL(),
          * it's possible that it contains copy of passed item
          */
         hb_ret();

         if( hb_itemGetWriteCL( pBuffer, &buffer, &ulSize ) )
            memset( buffer, ' ', ulSize );
      }
   }

And then use it:
   hb_setSpace( @pw )
Of course it will work only if pw was not assigned to some other
location and it's the one copy of given text.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to