This site is no longer active and is available for archival purposes only. Registration and login is disabled.

CreateFile() and the stack


CreateFile() and the stack

Postby wayne_s » Apr 30, 2004 @ 6:33pm

:?: Does anyone know if CreateFile() allocates memory on the stack?

The application I am writing opens a file (of variable size, but possibly large) at the start. It needs to read from this file often during execution, so I basically opened the file with CreateFile() and then left it. However, I seem to be running out of stack space later on in the program (at least I think that's the problem).

To get around the problem, I now use CloseHandle() as soon as I am done with the file, and then call CreateFile() again every time I need to re-access the data, and this seems to cause no problems.

Example (old method):

1. CFileHandler class opened file in constructor
2. CFileHandler class called CloseHandle() in destructor

The CFileHandler class is instantiated once at the beginning of my application (CFileHandler *handler = new CFileHandler()), and not destroyed until the program finishes.

Example (new method):
1. CFileHandler.ReadData calls CreateFile() at start
2. CFileHandler.ReadData calls CloseHandle() at end
3. No file handling is done in the constructor/destructor


Is this inefficient? Or is this how I should be doing things? Are there any other suggestions?

I am using eVC++ 3.0 and the PPC2002 emulator that comes with it.

Thanks![/code]
User avatar
wayne_s
pm Member
 
Posts: 2
Joined: Apr 30, 2004 @ 6:25pm
Location: Toronto, Ontario, Canada


Postby Peter Balogh » May 7, 2004 @ 7:24am

Download high quality games for your pda: www.pdamill.com
User avatar
Peter Balogh
pm Insider
 
Posts: 163
Joined: Dec 19, 2001 @ 7:54pm
Location: PDAmill HQ


Postby wayne_s » May 10, 2004 @ 4:28pm

User avatar
wayne_s
pm Member
 
Posts: 2
Joined: Apr 30, 2004 @ 6:25pm
Location: Toronto, Ontario, Canada


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron