malloc realloc and pointers
- From: ravi <nospam@xxxxxxxxxxxxxx>
- Date: Thu, 29 Nov 2007 21:50:38 +0100 (CET)
Hi all,
I m relatively new to C. I have few queries related to malloc():
1. When we perform malloc(), the memory allocated dynamically comes from
the heap area of the process in concern. Well, we then say that the heap
has shrinked. my query is: Is it that the heap physically does not
shrink but the perticular nodes are marked 'ALLOCATED' and for
subsequent calls to malloc() the memory manager remembers them and does
not reference them?
2. With realloc(), if some pointer 'ptr' is pointing initially to a
perticular position in a buffer (char *buffer) then on performing a
realloc() on this buffer, what will be 'ptr' pointing to?
3. whats the maximum memory size that we can allocate dynamically by
calling malloc() ?
4. Is it valid in C to typecast a pointer? eg. code snippet... of
course int is 16 bit and long is 32 bit.
int *variable, value;
*((long*)variable)++ = value;
*((long*)variable)++ = value;
*((long*)variable)++ = value;
*((long*)variable)++ = value;
thanx in advance
.
- Follow-Ups:
- Re: malloc realloc and pointers
- From: Jack Klein
- Re: malloc realloc and pointers
- From: CBFalconer
- Re: malloc realloc and pointers
- From: Kenneth Brody
- Re: malloc realloc and pointers
- From: Peter Nilsson
- Re: malloc realloc and pointers
- Prev by Date: Re: operators similar to functions?
- Next by Date: Re: Alignment of variables in structs
- Previous by thread: ~!!~ Turns your PC into a Super Entertainment Center - 100% FREE ~!!~
- Next by thread: Re: malloc realloc and pointers
- Index(es):
Relevant Pages
|