Overwrite content and length of any jString variable?
I have native C function (Example bellow) which as the parametr I give 'char* buffer' variable. To this buffer is placed received data and is returned length of received data (without any reallocation of memory).
Please, how can I do the same using JNI? Is it possible? I mean something like:
publicclass MySocket{
publicnativevoid receive(String str);
}
Where 'str' should be filled with received data of any length.
C example:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/** @return length of received data
*/
int receive(char *buffer,int bufLen){
/* EXAMPLE OF SAME DATA */
const char* dataFromNetwork ="_data_received_from_network";
/* FILL BUFFER WITH RECEIVED DATA */
strcpy (buffer, dataFromNetwork);
/* RETURN ITS LENGTH */
return strlen(buffer);
}
int main (){
constint bufLen = 100;
char buffer[bufLen];
/***** THIS METHOD DOES NOT AFFECTS ANY MEMORY ALLOCATION *****/
int recvLen = receive(buffer, bufLen);
}
return 0;
}
Any advice would be really, really appreciated.

