Hi all, I have a C function which is a call-back of a .dll, I need to call a .prg level function to pass to it the handling of that call-back action.
int my_c_func( void * buff ) { ... } my_c_func() gets called from the .dll and receives an allocated buffer, I want to pass it to a .prg level function which will fill it with some data and then I give control back to the .dll. Now I'm doing something like this, which does not work :) int read( void *ptr, int size, void * user_data ) { PHB_ITEM pObject = (PHB_ITEM) user_data; PHB_ITEM pItemBuffer = NULL; char * pBuffer = NULL; PHB_DYNS pSym_Read = hb_dynsymFindName( "READ" ); int res = 0; if ( pSym_Read && pObject ) { pItemBuffer = hb_itemNew( NULL ); pBuffer = malloc( size ); hb_itemPutCPtr( pItemBuffer, pBuffer, size ); hb_vmPushSymbol( hb_dynsymSymbol( pSym_Read ) ); hb_vmPush( pObject ); hb_vmPushItemRef( pItemBuffer ); hb_vmPushLong( size ); hb_vmSend( 2 ); res = hb_parnl( -1 ); memcpy( ptr, pBuffer, res ); hb_itemRelease( pItemBuffer ); } return res; } I'd like not to have to copy that buffer from C to PHB_ITEM and then back to C and, most of all, to make it work! So, question is: what is the correct way to pass a C buffer to a PRG function by reference so that the PRG function (in my case its a method, but I think this does not make such a difference) can change it and then remove this buffer from the HB_ITEM so that the C code can keep using it? Thanks! Maurilio. -- __________ | | | |__| Maurilio Longo |_|_|_|____| farmaconsult s.r.l. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ xHarbour-developers mailing list xHarbour-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xharbour-developers