🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #828

File pointer to a memory location?

#828
From: Randy Tidd
Date: Mon, 10 Sep 1990 16:46
34 lines
2140 bytes
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@mwunix.mitre.org			FAST
#define DISCLAIM TRUE			CHEAP
						-pick any two
Technical Details
Message-ID: <119609@linus.mitre.org>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!linus!linus!ccels3.mitre.org!rtidd

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!linus!linus!ccels3.mitre.org!rtidd
From: rtidd@ccels3.mitre.org (Randy Tidd)
Newsgroups: comp.unix.programmer,comp.unix.internals
Subject: File pointer to a memory location?
Message-ID: <119609@linus.mitre.org>
Date: 10 Sep 90 16:46:02 GMT
Sender: usenet@linus.mitre.org
Reply-To: rtidd@ccels3.mitre.org (Randy Tidd)
Followup-To: comp.unix.programmer
Organization: The Mitre Corporation
Lines: 34