Re: malloc



milinddeore@xxxxxxxxx wrote:
santosh wrote:
ramu wrote:
<snip>
If I use both the calls ie. malloc and realloc together, how the allocated memory will be
ie. contiguous or not?
<snip>
2.
double *d1 = malloc(100 * sizeof *d1);
double *d2 = realloc(d2, 100 * sizeof *d2);
Here the elements of d1 have no necessary relationship with elements of
d2, i.e. pointer arithmetic will not work _across_ them, though within
each block, elements can be regarded as contiguous.
<snip>
$$ Good mathematics, but of no use.

Are you disputing the statement that elements within a single
allocation of memory in standard C can be _regarded_ as contiguous?

What if brk/sbrk gives new pages, as the old page is over.

The C standard says nothing about 'brk/sbrk'.

For your information pages are just the
virtual mapping and not guaranteed that they will come contiguous
memory manner.

For your information 'virtual memory' and paging are neither required
by the standard, nor likely to be present on a lot of conforming
implementations.

DOS and embedded systems are the most obvious counter examples.

.



Relevant Pages

  • Re: A solution for the allocation failures problem
    ... Can you find anything in the standard which *allows* this behaviour? ... it defines how your C program is supposed to behave. ... previously allocated memory available for further allocation. ... says the memory will be made available for further allocation. ...
    (comp.lang.c)
  • Re: Target market for Intellasys.
    ... I would like to see a full speed general purpose embedded serial interconnect IO bus standard. ... Looking through serial memory I found something like a maximum of 70mhz speed which is pretty useless if it was the only bus in a cutting edge design. ... All other control mode levels also have this ability, to allow developer to instigate their own versions of the features not defined in that level, as they wish, if they wish. ...
    (comp.lang.forth)
  • Re: Copying pthread_t
    ... Where is this different from all the other functions in the standard? ... object is modified through one pointer while the other pointer is ... each 'pthread_t' could have some memory allocated to ... initialize a pthread_t is by one of the pthread_* functions like ...
    (comp.programming.threads)
  • Re: Why no folder manipulation in Std C
    ... obeys every other requirement laid out in the standard. ... correctly execute the "one program" doesn't guarantee anything about ... implementation creates machine code for the "one program" that attempts ... platform which doesn't have enough memory to allow such an object to be ...
    (comp.std.c)
  • Re: close fd while select/poll/epoll
    ... |> does the closing of the descriptor until after the select/poll. ... If the kernel conforms to a standard I have in mind, ... get EBADF if the descriptor is already closed by the time pollenters ... suppose we allocate more memory than the system has. ...
    (comp.os.linux.development.system)