File pointer to a memory location?

Randy Tidd rtidd at ccels3.mitre.org
Tue Sep 11 02:46:02 AEST 1990


With all these new comp.unix.* groups coming out, I hope it's
appropriate to cross-post to .programmer and .internals...

Anyhow, in the application i'm working on I have a series of routines
that were written by someone else that do image processing (the fbm
library, if you're familiar with it), including source.  These
routines take a file pointer as an argument, and they read the
image-to-be-processed through this fp.  Normally what you do is open a
file and pass in a file pointer to it, or pass in stdin and pipe your
image through the program through the shell.

The problem is in my application, I am using a database and thus don't
have files and thus I don't have file pointers either.  What I *can*
do is query the database for an image, and it gives me a block of
memory that holds the image *exactly* as it is stored in file form.

So what I have is a block of memory, having exactly the same size and
contents of a file. What I have to do is pass my image processing
routines a file pointer that points to this block of memory.  If the
routines used file *descriptors*, it wouldn't be a problem because I
could just use pipes and be done with it.

What I do now is query the database, get a block of memory, dump this
memory to a temporary file, open the file with a file pointer, and
pass the file pointer to the image processing routines.  Not only is
this dumb, but images can be a big as 3 megs and this is incredibly
inefficient.

Can anyone help me out?

Randy Tidd				GOOD
rtidd at mwunix.mitre.org			FAST
#define DISCLAIM TRUE			CHEAP
						-pick any two



More information about the Comp.unix.programmer mailing list