473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

portable fmemopen

i have a vendor function, which need to take into FILE* as function
arguement.

vendor_function_read_and_process(FILE* f)

however, by reading from disk file during run-time, we get performance
penalty.

hence, instead of having f pointing to a disk file, we would like to
have f mapped to a memory location.

fmemopen is what we are looking for. however, since we are developing
is MSVC windows platform, i was wondering whether there is any portable
library to do so?

thank you.

Nov 15 '06 #1
3 4839
ya************@gmail.com wrote:
i have a vendor function, which need to take into FILE* as function
arguement.

vendor_function_read_and_process(FILE* f)

however, by reading from disk file during run-time, we get performance
penalty.
Who says that f has to control a disk file? Is it under your control or
not?
hence, instead of having f pointing to a disk file, we would like to
have f mapped to a memory location.
f is just a pointer to an object of type FILE. That too, despite it's
name, is probably a simple structure object. f will control a disk
file, only if you make it do so by a call to fopen() or similar. If you
want to map that disk file, whatever it is, to memory then memory
mapped files is the first idea.
fmemopen is what we are looking for. however, since we are developing
is MSVC windows platform, i was wondering whether there is any portable
library to do so?
I suspect, memory mapping the file using the native Windows API would
be sufficient unless the requirements are special. Even then you'll not
be able to avoid the overall penalty incurred in reading it ina
piecemeal fashion from the hard disk.

Anyway, standard C has no provisions for what you're seeking. Ask in a
Microsoft newsgroup like comp.os.ms-windows.programming.

Nov 15 '06 #2

<ya************@gmail.comwrote in message
news:11********************@m7g2000cwm.googlegroup s.com...
>i have a vendor function, which need to take into FILE* as function
arguement.

vendor_function_read_and_process(FILE* f)

however, by reading from disk file during run-time, we get performance
penalty.

hence, instead of having f pointing to a disk file, we would like to
have f mapped to a memory location.

fmemopen is what we are looking for. however, since we are developing
is MSVC windows platform, i was wondering whether there is any portable
library to do so?
Sadly, this is a major weakness in the standard. There is no way of creating
memory files or indeed and user-defined type of stream.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
Nov 15 '06 #3
"Malcolm" <re*******@btinternet.comwrites:
<ya************@gmail.comwrote in message
news:11********************@m7g2000cwm.googlegroup s.com...
[...]
>fmemopen is what we are looking for. however, since we are developing
is MSVC windows platform, i was wondering whether there is any portable
library to do so?
Sadly, this is a major weakness in the standard. There is no way of creating
memory files or indeed and user-defined type of stream.
There's no standard way of specifying that a given file exists in
memory. But then again, there's no standard way of specifying that a
given file exists on disk. The interpretation of a file name is
entirely system-specific.

An implementation could easily specify a particular form of file name
that refers to in-memory files; then all the machinery that normally
deals with disk files should just work. I wonder why more
implementations don't do this.

(Some implementations can implement in-memory file systems, but
there's no good way to tell that a given file is on such a file
system. For example, <OT>"/tmp" might be implemented as swapfs on one
system, as a physical disk on another, and even as a remote
NFS-mounted filesystem on yet another, with all three systems running
the same version of the same operating system.</OT>)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: James Harris | last post by:
Hi, Can someone recommend a book that will teach me how to approach C programming so that code is modularised, will compile for different environments (such as variations of Unix and Windows),...
14
by: Markus Dehmann | last post by:
The following if condition if((stream = fmemopen((void*)str, strlen(str), "r")) == NULL){ // ... } gives me a warning: assignment makes pointer from integer without a cast But only when I...
5
by: Markus Dehmann | last post by:
In the GNU C library (stdio.h), there is a function FILE* fmemopen (void *buf, size_t size, const char *opentype) It opens a FILE stream that allows read or write access to the buffer buf. ...
10
by: Jason Curl | last post by:
Dear C group, I'm very interested in writing portable C, but I only have GNU, Sparc and Cygwin to compile on. What I find is the biggest problem to writing portable C is what headers to...
131
by: pemo | last post by:
Is C really portable? And, apologies, but this is possibly a little OT? In c.l.c we often see 'not portable' comments, but I wonder just how portable C apps really are. I don't write...
3
by: yancheng.cheok | last post by:
i have a vendor function, which need to take into FILE* as function arguement. vendor_function_read_and_process(FILE* f) however, by reading from disk file during run-time, we get performance...
409
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.