Click here to Skip to main content
15,918,168 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Neville Franks26-Dec-02 13:13
Neville Franks26-Dec-02 13:13 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger26-Dec-02 13:30
professionalChris Losinger26-Dec-02 13:30 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Neville Franks26-Dec-02 13:46
Neville Franks26-Dec-02 13:46 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger26-Dec-02 13:50
professionalChris Losinger26-Dec-02 13:50 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Neville Franks26-Dec-02 13:57
Neville Franks26-Dec-02 13:57 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger26-Dec-02 14:16
professionalChris Losinger26-Dec-02 14:16 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Neville Franks26-Dec-02 14:39
Neville Franks26-Dec-02 14:39 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger26-Dec-02 15:13
professionalChris Losinger26-Dec-02 15:13 
Neville Franks wrote:
Have you actually proved there is a problem with fopen et.all.?

yes, a 2 minute DLL project can prove this:

in a DLL:

typedef struct strct_t
{
   FILE *fp;
} strct;

void __stdcall OpenAFile(strct * theStruct)
{
   theStruct->fp = fopen("c:\\autoexec.bat", "r");
}


in the EXE:

strct s;
OpenAFile(&s);
fclose(s.fp);


it crashes in the fclose.

Neville Franks wrote:
Looking at the CRT code it uses _malloc_crt() to allocate a stream object.

and then it associates one of the entries in the __piob array to the stream. this array is global to the CRT instance (look in crt\src\_file.c).

a quick skip through Google will show dozens of instances of this problem. and the answer is always "use CreateFile" or "link to a shared CRT". unfortunately, the second is not an option for me, either.

the problem is really: how to make ReadFile/WriteFile behave in a manner worthy of being the low-level file operation on a modern OS?

-c



I'm not the droid you're looking for.

GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Neville Franks26-Dec-02 15:50
Neville Franks26-Dec-02 15:50 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Matt Gullett26-Dec-02 15:49
Matt Gullett26-Dec-02 15:49 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger26-Dec-02 19:00
professionalChris Losinger26-Dec-02 19:00 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Michael Dunn26-Dec-02 18:52
sitebuilderMichael Dunn26-Dec-02 18:52 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger26-Dec-02 18:59
professionalChris Losinger26-Dec-02 18:59 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Mike Nordell27-Dec-02 1:22
Mike Nordell27-Dec-02 1:22 
GeneralRe: WriteFile = slow; fwrite = fast; me = sad; Pin
Chris Losinger27-Dec-02 6:27
professionalChris Losinger27-Dec-02 6:27 
GeneralControls on an MDI App Pin
Steven M Hunt26-Dec-02 11:51
Steven M Hunt26-Dec-02 11:51 
GeneralLIB from DLL Pin
Hockey26-Dec-02 11:30
Hockey26-Dec-02 11:30 
GeneralRe: LIB from DLL Pin
Neville Franks26-Dec-02 13:06
Neville Franks26-Dec-02 13:06 
GeneralRe: LIB from DLL Pin
Hockey26-Dec-02 17:35
Hockey26-Dec-02 17:35 
GeneralRe: LIB from DLL Pin
Neville Franks26-Dec-02 18:51
Neville Franks26-Dec-02 18:51 
GeneralRe: LIB from DLL Pin
Chris Losinger26-Dec-02 15:15
professionalChris Losinger26-Dec-02 15:15 
GeneralRe: LIB from DLL Pin
Hockey26-Dec-02 17:37
Hockey26-Dec-02 17:37 
GeneralRe: LIB from DLL Pin
Mike Nordell27-Dec-02 1:25
Mike Nordell27-Dec-02 1:25 
Generalthree views + three opengl windows + crashes when fullscreen Pin
bbbilen26-Dec-02 9:54
bbbilen26-Dec-02 9:54 
GeneralRe: three views + three opengl windows + crashes when fullscreen Pin
KaЯl26-Dec-02 23:49
KaЯl26-Dec-02 23:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.