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

C / C++ / MFC

 
GeneralRe: Allocating memory for a large array. Pin
jonsey2984727-Feb-08 5:17
jonsey2984727-Feb-08 5:17 
GeneralRe: Allocating memory for a large array. Pin
led mike27-Feb-08 4:54
led mike27-Feb-08 4:54 
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 
jonsey29847 wrote:
my struct is simple 3 pointers to TCHARs


That is a perfect example of "not simple".

TCHAR * is an address in memory to a block of TCHAR where the length of the block is undefined in your structure, which Mark Salsbery has pointed out.

Therefore when you allocate the memory for the struct on the stack only the 4 byte address member is allocated, not the space you need to hold the string you want that to point to.

Even if you calculate the space required and allocate on the heap you still don't have the memory structure you think you do in the struct and you would have to use math to address the starting points in memory to all the space you allocated for those strings. That is not advisable or Best Practice by the way.

jonsey29847 wrote:
My score is about 3 for 5 here


It's possible you may not have accurately assessed your situation.


led mike

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 
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 

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.