Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 20th, 2012  |  syntax: None  |  size: 1.14 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JNA Error at Program Exit
  2. __declspec(dllexport) extern "C"
  3. char** get_prop_types( int* count ) {
  4.   const vector<string>& r = prop_manager::get_prop_types();
  5.   char **p = (char**)malloc( r.size() );
  6.   char **ptr = p;
  7.   for( vector<string>::const_iterator it = r.begin(); it!=r.end() ; ++it ) {
  8.     *p = (char*)malloc( it->size() );
  9.     strcpy(*p++,it->c_str());
  10.   }
  11.   *count = r.size();
  12.   return ptr;
  13. }
  14.        
  15. public interface Arch extends Library {
  16.     public Pointer get_prop_types( IntByReference size );
  17. }
  18. static Arch theLib; //initialization not shown
  19.  
  20. public static String[] getPropTypes() {
  21.     IntByReference size = new IntByReference();
  22.     Pointer strs = theLib.get_prop_types(size);
  23.     //free is apparently handled for us?
  24.     return strs.getStringArray(0, size.getValue());
  25. }
  26.  
  27. public static void main( String[] args ) {
  28.     System.out.println( Arrays.toString(getPropTypes()) );
  29. }
  30.        
  31. The instruction at "%08X" referenced memory at "%08x". The memory could not be "read".
  32.        
  33. *p = (char*)malloc( it->size() );
  34.        
  35. *p = (char*)malloc( it->size() + 1);
  36.        
  37. char **p = (char**)malloc( r.size() );
  38.        
  39. char **p = (char**)malloc( r.size() * sizeof(char *) );