Thread: Array memory map

  1. #1
    Registered User
    Join Date
    Jun 2003

    Array memory map

    Just some clarification if you wouldn't mind.

    If I allocated an array like so:

    char MyBuffer[127][256];

    Would I get a guaranteed contiguous buffer of 32512 bytes (127*256), or would some implementations of C only guarantee 256 bytes in one contiguous chunk?

    Or, in other words, is the above equivalent to:

    char MyBuffer[32512];

    Apart from the way you access it?

    I want to clear the entire array to zeros without using a for loop to do each element. If the entire array is guaranteed to be contiguous, then I can just call ZeroMemory once instead of 127 times.

  2. #2
    Registered User
    Join Date
    Aug 2003
    It will never be equal to a 32512 array as char ** is not a char * and it never will be. I don't see a problem with looping, no matter how you choose to zero it (high level) it will turn out to be a loop in the compiled code.

    Arrays of all kinds are contiguous (by definition).

  3. #3
    Registered User
    Join Date
    Jun 2003
    Thanks for the clarification.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help -- allocating memory in a multidimensional array
    By jonathan.plumb in forum C Programming
    Replies: 10
    Last Post: 05-20-2009, 11:04 PM
  2. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  3. How to Map a Memory Space
    By jacob12 in forum C Programming
    Replies: 6
    Last Post: 10-04-2008, 10:19 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM