Click here to Skip to main content
15,890,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralVC++ linker error Pin
Member 384040618-Feb-07 3:42
Member 384040618-Feb-07 3:42 
GeneralRe: VC++ linker error Pin
Waldermort18-Feb-07 3:47
Waldermort18-Feb-07 3:47 
GeneralRe: VC++ linker error Pin
Hamid_RT18-Feb-07 6:25
Hamid_RT18-Feb-07 6:25 
GeneralRe: VC++ linker error Pin
Hamid_RT18-Feb-07 4:55
Hamid_RT18-Feb-07 4:55 
GeneralRe: VC++ linker error Pin
Jeffrey Walton18-Feb-07 5:44
Jeffrey Walton18-Feb-07 5:44 
GeneralRe: VC++ linker error Pin
cruppstahl18-Feb-07 7:35
cruppstahl18-Feb-07 7:35 
NewsCode Snippets Manager Pin
marvviki18-Feb-07 2:42
marvviki18-Feb-07 2:42 
Questionmemory mapped I/O and private copies Pin
cruppstahl18-Feb-07 2:28
cruppstahl18-Feb-07 2:28 
Hi!

I'm porting a library from unix/posix to Win32, and i have some troubles with the memory mapped file access.

I use mmap to read pages from the file, but use the normal write API to write the pages.

On unix, it looks like this:


buffer=mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, position);

On win32, it's a bit longer, as usual:

DWORD fsize=GetFileSize(fd, 0);

mmaph=CreateFileMapping(fd, 0, PAGE_READONLY, 0, fsize, 0);

buffer=MapViewOfFile(mmaph, PAGE_READWRITE, 0, (unsigned long)position, size);

My first problem is that CreateFileMapping is called whenever i read a page from the file. Is it an expensive operation? I just don't see a way to avoid this. If i cache the mmaph handle, and the file is resized because a page is appended, then this page is not covered by the file mapping...

The second problem: it just doesn't work. CreateFileMapping returns 0 and GetLastError is 5 (ACCESS_DENIED) when it's called for the very first time (fd is a valid file handle, and fsize is 4096).

The file handle was created with
CreateFile(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED, 0);

Thanks for any help
Chris
AnswerRe: memory mapped I/O and private copies Pin
Waldermort18-Feb-07 3:17
Waldermort18-Feb-07 3:17 
GeneralRe: memory mapped I/O and private copies Pin
cruppstahl18-Feb-07 7:23
cruppstahl18-Feb-07 7:23 
QuestionHow to load text file into an array of structures..? [modified] Pin
Software_Specialist18-Feb-07 2:06
Software_Specialist18-Feb-07 2:06 
AnswerRe: How to load text file into an array of structures..? Pin
Waldermort18-Feb-07 3:11
Waldermort18-Feb-07 3:11 
GeneralRe: How to load text file into an array of structures..? Pin
Software_Specialist18-Feb-07 4:36
Software_Specialist18-Feb-07 4:36 
GeneralRe: How to load text file into an array of structures..? Pin
Waldermort18-Feb-07 5:11
Waldermort18-Feb-07 5:11 
GeneralRe: How to load text file into an array of structures..? Pin
David Crow18-Feb-07 16:29
David Crow18-Feb-07 16:29 
GeneralRe: How to load text file into an array of structures..? Pin
Waldermort18-Feb-07 18:24
Waldermort18-Feb-07 18:24 
GeneralRe: How to load text file into an array of structures..? Pin
Software_Specialist19-Feb-07 1:53
Software_Specialist19-Feb-07 1:53 
AnswerRe: How to load text file into an array of structures..? Pin
Bram van Kampen19-Feb-07 13:30
Bram van Kampen19-Feb-07 13:30 
Questiondispaly thambnails of the images on the view Pin
vasu_sri18-Feb-07 0:33
vasu_sri18-Feb-07 0:33 
AnswerRe: dispaly thambnails of the images on the view Pin
Hamid_RT18-Feb-07 4:41
Hamid_RT18-Feb-07 4:41 
QuestionRe: dispaly thambnails of the images on the view Pin
Mark Salsbery18-Feb-07 7:19
Mark Salsbery18-Feb-07 7:19 
QuestionResource Localization (Polish Character) Pin
Anik3318-Feb-07 0:28
Anik3318-Feb-07 0:28 
AnswerRe: Resource Localization (Polish Character) Pin
ovidiucucu18-Feb-07 12:38
ovidiucucu18-Feb-07 12:38 
Questiondisplaying the thumbnail preview of the images on the view Pin
vasu_sri17-Feb-07 22:05
vasu_sri17-Feb-07 22:05 
AnswerRe: displaying the thumbnail preview of the images on the view Pin
Hamid_RT18-Feb-07 4:40
Hamid_RT18-Feb-07 4:40 

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.