1

//cpp code

ifstream myfile;

myfile.open("D:\Spot\data\simpledata.txt");

string content((std::istreambuf_iterator(myfile)),
(istreambuf_iterator()));
myfile.close();
char* chr = &content[0];
return char;

//node code

var libSpotcolor = ffi.Library(fileName, {
'test': ["char *", []]
});

var testdata =libSpotcolor.test(); // Here node is crashing

console.log(testdata);

var save_json = testdata.readCString();

can i get more the 1 mb data , If not is any alternate way to get this ?

BONDbATIF
  • 113
  • 1
  • 2
  • 6
  • Why don't you use node [filesystem module](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) ? – Serge K. Nov 13 '17 at 09:48
  • Hi, there are 3rd party software: https://github.com/nickewing/line-reader https://github.com/jahewson/node-byline https://github.com/pkrumins/node-lazy https://github.com/Gagle/Node-BufferedReader – PRADEEP Kumar Nov 13 '17 at 09:48
  • Already answered Ref: [Parsing huge file](https://stackoverflow.com/a/23695940/8281584) – PRADEEP Kumar Nov 13 '17 at 09:50
  • i have to get data from dll and store into a variable.So i dont want to use filesystem module.node-ffi is a Node.js addon for loading and calling dynamic libraries using pure JavaScript. – BONDbATIF Nov 13 '17 at 10:02
  • `any alternative` Like @SergeK. says, using node would be the best option. There are thousands of NPM modules nowadays. Saying this, for the rare occasions I have had to integrate with none node stuff, the best option I've found is using Stdio, you basically create a simple protocol to send the information between them, stdio is fast & cross platform too. – Keith Nov 13 '17 at 11:31
  • Could you provide details about the crash? – vsenko Nov 14 '17 at 10:28
  • Thank you eveybody. i found the problem. The problem memory was deallocation. So i got the idea from http://jakegoulding.com/rust-ffi-omnibus/string_return/ and implemented in cpp – BONDbATIF Nov 14 '17 at 11:31

0 Answers0