I am trying to work with memory addresses back n forth..
Simple case of char* buffer that needs to be filled in by dll . Buffer does
not change in Pharo after the call. Am I missing something here..
The memory address that is printed out does not match what I see in Pharo /
infact the address does not change at all... for repeated call invoked from
debugger.
C Code:
DLLEXPORT int readAndWritePipe(char* outBuf )
{
system("Echo readAndWritePipe" );
debugPrintf ( "readAndWritePipe: %d \n" , &outBuf , 1046 );
memcpy ( outBuf , "Testing123\0" , 11) ;
return 0;
}
void debugPrintf ( char* logString, int intArg , char* strArg, int size )
{ // can redirect as needed to logger end point..
FILE * logFile = fopen( "c:\\temp\\writePipes.log" , "a" );
char* buf = (char*) calloc( sizeof(char) , size );
sprintf( buf, logString , intArg , strArg );
fputs(buf , logFile );
fclose(logFile);
}
Pharo:
testPharoBuffer: buf
<primitive: #primitiveNativeCall module: #NativeBoostPlugin error:
errorCode >
^ self nbCall: #( int readAndWritePipe( String buf ) ) module:
'TestPharo.dll'
testPharoBuffer
"self new testPharoBuffer "
| buf addr addr2 |
buf := String new: 100000.
addr := buf asNBExternalString.
addr2 := ( NativeBoost allocate: 256 ).
self testPharoBuffer: addr . " or use addr2, both of it does not
work"
Transcript cr; show: buf.