View Single Post
Old 03-21-2005, 12:01 PM   #3 (permalink)
santechz
 
Newb Techie

Join Date: Mar 2005

Posts: 3

santechz

Default

this is how i visualize my question


char * p1 = (char*)malloc(sizeof(char)); //sizeof(char)=1 byte
char * p2 = (char*)malloc(sizeof(char));

now i get p1 = 1460
then p2 must be 1461 (or 1462 for adjustment) if there were no allocation to heap in between these two statements, bcoz this would be the easiest to implement the heap management....

but i get p2 = 1468. in other words, there are 7 bytes which I believe I can use. Why did malloc return 1468 and not 1461(/1462)? Can i really use these 7 bytes. will the heaper (?) allocate these 7 bytes (even when i havent freed p1 and p2) when i request a ..say malloc(4 * sizeof(char))?

regards
santechz is offline