Re: How to make malloc() fail ?
- From: Bernhard Müller <nospam@xxxxxxxxxx>
- Date: Sun, 22 Jul 2007 21:24:56 +0200
santosh wrote:
On Wednesday 18 Jul 2007 1:15 pm, in comp.lang.c, Daniel Rudyreplace 0xFFFFFFFF with (size_t)-1 or the macro SIZE_MAX (from <stdint.h>; size_t is not guaranteed to be unsigned), that's more portable anyway - 64bit machines are real-world things already.
<spamthis@xxxxxxxxxxxx> wrote:
Message ID: <Cyjni.9381$eY.6720@xxxxxxxxxxxxxxxxxxxxxxxxxx>
At about the time of 7/17/2007 3:36 AM, niranjan.singh@xxxxxxxxx
stated the following:
This is regarding to test an SDK memory stuff.
In what situation malloc gets fail.
any comment/reply pls....
regards
something like this:
ptr = malloc(0xFFFFFFFF);
That will usually cause the allocation to fail...
Many modern workstations have 4 Gb or more of memory installed.
Other point if you actually want libc's malloc to fail or if you want to verify the application's response to a failing malloc. for the latter case try replacing libc's malloc by another function implementing the same interface. There are ways to do so without or with little modifications to the tested code.
bm
--
Bernhard Mueller
bernhard dot mueller at
.
- Follow-Ups:
- Re: How to make malloc() fail ?
- From: Flash Gordon
- Re: How to make malloc() fail ?
- References:
- How to make malloc() fail ?
- From: niranjan.singh@xxxxxxxxx
- Re: How to make malloc() fail ?
- From: Daniel Rudy
- Re: How to make malloc() fail ?
- From: santosh
- How to make malloc() fail ?
- Prev by Date: Re: Read a 8-bit grayscale JPEG image.
- Next by Date: Re: I want unsigned char * string literals
- Previous by thread: Re: How to make malloc() fail ?
- Next by thread: Re: How to make malloc() fail ?
- Index(es):
Relevant Pages
|