Click here to Skip to main content
16,011,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 5:19
jonsey2984727-Feb-08 5:19 
GeneralRe: Allocating memory for a large array. Pin
led mike27-Feb-08 5:53
led mike27-Feb-08 5:53 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 6:20
jonsey2984727-Feb-08 6:20 
GeneralRe: Allocating memory for a large array. Pin
led mike27-Feb-08 6:48
led mike27-Feb-08 6:48 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 10:53
jonsey2984727-Feb-08 10:53 
GeneralRe: Allocating memory for a large array. Pin
led mike27-Feb-08 11:19
led mike27-Feb-08 11:19 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 12:01
jonsey2984727-Feb-08 12:01 
GeneralRe: Allocating memory for a large array. [Solved -- Update] Pin
jonsey2984729-Feb-08 8:23
jonsey2984729-Feb-08 8:23 
led mike,

This is what I have taken away from all this;

1. An array does not have to reside in contigous memory, thus I was not corrupting the code, I found something interesting that was causing the apparent (debug only) problem, and a bug in my code.

2. As each element of an array is initialized the operating system will take care of pointer offsets. Duh?

3. In the function that reads the file and populates the array I am using LocalAlloc(LPTR, MaxSize) to initialize intermeadiate variables to hold the data as it is read. I am reinitializing theses variables by using the strcpy function to copy an empty string into the variable. My thinking is that the best practice would be to use ZeroMemory to to reinitialize, this should cover the possiblity of random data causing some kind of problem.

Last night I purchased Petzolds book from Amazon, and I have online access to it neat eh, I have already learned a few neat tricks that I can't wait to use.

Thanks for your help.
GeneralRe: Allocating memory for a large array. Pin
Iain Clarke, Warrior Programmer27-Feb-08 5:12
Iain Clarke, Warrior Programmer27-Feb-08 5:12 
GeneralRe: Allocating memory for a large array. Pin
CPallini27-Feb-08 5:20
mveCPallini27-Feb-08 5:20 
GeneralRe: Allocating memory for a large array. Pin
Iain Clarke, Warrior Programmer27-Feb-08 5:26
Iain Clarke, Warrior Programmer27-Feb-08 5:26 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 5:22
jonsey2984727-Feb-08 5:22 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 5:32
jonsey2984727-Feb-08 5:32 
GeneralRe: Allocating memory for a large array. Pin
Mark Salsbery27-Feb-08 5:47
Mark Salsbery27-Feb-08 5:47 
GeneralRe: Allocating memory for a large array. Pin
Iain Clarke, Warrior Programmer27-Feb-08 5:51
Iain Clarke, Warrior Programmer27-Feb-08 5:51 
GeneralRe: Allocating memory for a large array. Pin
Mark Salsbery27-Feb-08 5:54
Mark Salsbery27-Feb-08 5:54 
GeneralRe: Allocating memory for a large array. Pin
Iain Clarke, Warrior Programmer27-Feb-08 6:05
Iain Clarke, Warrior Programmer27-Feb-08 6:05 
GeneralRe: Allocating memory for a large array. Pin
Mark Salsbery27-Feb-08 6:07
Mark Salsbery27-Feb-08 6:07 
QuestionRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 5:53
jonsey2984727-Feb-08 5:53 
GeneralRe: Allocating memory for a large array. Pin
Mark Salsbery27-Feb-08 6:04
Mark Salsbery27-Feb-08 6:04 
GeneralRe: Allocating memory for a large array. Pin
Iain Clarke, Warrior Programmer27-Feb-08 5:49
Iain Clarke, Warrior Programmer27-Feb-08 5:49 
QuestionRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 6:02
jonsey2984727-Feb-08 6:02 
GeneralRe: Allocating memory for a large array. Pin
Mark Salsbery27-Feb-08 6:06
Mark Salsbery27-Feb-08 6:06 
QuestionRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 6:33
jonsey2984727-Feb-08 6:33 
GeneralRe: Allocating memory for a large array. Pin
Mark Salsbery27-Feb-08 6:45
Mark Salsbery27-Feb-08 6:45 

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.