Why do you want to allocate 4GB of RAM? Are you on a 64-bit system?
Think about how you might represent 256*256*256*256+1000 in 32 bits.
Also think about how 256*256*256*256-1 might be represented, and what the value of the MSB will be, and what malloc will do if it's asked to allocate a negative amount of memory.