Re: Test if pointer points to allocated memory
In article <6d1334df.04012 12316.5b824cab@ posting.google. com>,
rahul_dev_agg@h otmail.com (rahul dev) wrote:
[color=blue]
> malloc() library function uses brk() and sbrk() to increase the
> address space of a process.[/color]
Does it? I always thought it called NewPtr (). Oh, I see, you are
talking about completely system dependent behavior that only a complete
idiot would rely on in portable code...
[color=blue]
> sbrk() is a system call that ask
> the kernel to allocate space at the end of "data segment" of
> the process.[/color]
Since I use a machine that doesn't have sbrk(), or a kernel, or a data
segment, of use could that information be?
[color=blue]
> So, the address returned by malloc() should always
> be greater than the end of data segment.
> Now, the end of data segment may be found by printing the address
> of the symbol "end" or the address of the symbol "_end". These
> symbols are defined with the appropriate values by the linker.
> Or you may use "objdump" to find out the addresses of data segments
> of your executable.
>
> -rd[/color]
In article <6d1334df.04012 12316.5b824cab@ posting.google. com>,
rahul_dev_agg@h otmail.com (rahul dev) wrote:
[color=blue]
> malloc() library function uses brk() and sbrk() to increase the
> address space of a process.[/color]
Does it? I always thought it called NewPtr (). Oh, I see, you are
talking about completely system dependent behavior that only a complete
idiot would rely on in portable code...
[color=blue]
> sbrk() is a system call that ask
> the kernel to allocate space at the end of "data segment" of
> the process.[/color]
Since I use a machine that doesn't have sbrk(), or a kernel, or a data
segment, of use could that information be?
[color=blue]
> So, the address returned by malloc() should always
> be greater than the end of data segment.
> Now, the end of data segment may be found by printing the address
> of the symbol "end" or the address of the symbol "_end". These
> symbols are defined with the appropriate values by the linker.
> Or you may use "objdump" to find out the addresses of data segments
> of your executable.
>
> -rd[/color]
Comment