Maurilio,

The only problem I see is in the sample code - it had a memory  
overrun and memory leaks. Here is the corrected sample:

//---------------------------------------------------------------------- 
------------//
PROCEDURE main()

    LOCAL cStr := "Hello"

    MemoWrit( "test.txt", Replicate( "0", 2048 ) )

    ? Test()

    fErase( "test.txt" )

RETURN


PROCEDURE Called( cStr )

    LOCAL nHandle

    nHandle := fOpen( "test.txt" )

    ? Len( cStr )
    ? fRead( nHandle, @cStr, Len( cStr ) )

    fClose( nHandle )

RETURN


#pragma begindump

#include <hbapi.h>
#include <hbapiitm.h>
#include <hbvm.h>


HB_FUNC( TEST )
{
    PHB_DYNS pSym = hb_dynsymFindName( "CALLED" );
    PHB_ITEM pItem = hb_itemNew( NULL );
    char * pBuffer = NULL;

    pBuffer = (char *) hb_xgrab( 100 );
    hb_itemPutCPtr( pItem, pBuffer, 99 ); // NOTE!

    hb_vmPushSymbol( hb_dynsymSymbol( pSym ) );
    hb_vmPushNil();
    hb_vmPushItemRef( pItem );
    hb_vmDo( 1 );

    hb_itemReturnForward( pItem ); //NOTE!
    hb_itemRelease( pItem ); //NOTE!
}

#pragma enddump
//---------------------------------------------------------------------- 
------------//

Ron

On Jun 20, 2008, at 4:51 AM, Maurilio Longo wrote:

> Ron,
>
> fRead() has problems when some C code tries to pass to it a  
> variable by-reference.
>
> See attached sample, I think this is strictly correlated to my  
> previous posts
> about similar issues.
>
> Can this be solved?
>
> Can someone help me find the source of this issue so that I can try  
> to fix it
> by myself?
>
> TIA.
>
> Maurilio.
>
>
> -- 
>  __________
> |  |  | |__| Maurilio Longo
> |_|_|_|____| farmaconsult s.r.l.
>
> <ref.prg>------------------------------------------------------------ 
> -------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/ 
> index.php_______________________________________________
> xHarbour-developers mailing list
> xHarbour-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xharbour-developers



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to