views:

46

answers:

3

I would like to know if it is possible to read and write data from and to memory with ANSI C code instead of from a file. I have C code that is called from within an Objective C class many times and each time, it has to read in the same large binary file, do some processing on it, and then write out a large binary file (which is slightly different each time the code is called)

Ideally, I would like to somehow pass the large binary input file from Objective C into the ANSI C code and also pass back the large binary output file from the ANSI C code into Objective C.

Any ideas how to do this would be greatly appreciated.

A: 

It's not ANSI, but gcc has fmemopen and open_memstream which may help.

nategoose
there is no fmemopen for MacOSX, its linux specific.
Anders K.
I would have thought that it was glibc specific.
nategoose
+1  A: 

You can achieve something like that if you use funopen

check out

Anders K.
A: 

Can you give a very basic example of how to use funopen?

Dan