Re: why no palloc() ("permanent alloc")?
- From: phil-news-nospam@xxxxxxxx
- Date: 20 Jul 2008 15:46:44 GMT
On Sat, 19 Jul 2008 19:33:39 -0700 Paul Pluzhnikov <ppluzhnikov-nsp@xxxxxxxxx> wrote:
| Barry Margolin <barmar@xxxxxxxxxxxx> writes:
|
|> The warnings aren't about unreachable pointers, they're for pointers
|> that are never freed. They're needed until the end of the program, so
|> he's happy with letting the system free them when the process exits.
|> But valgrind doesn't know this.
|
| Actually, valgrind knows this perfectly well, and wouldn't be quite
| as useful as it is if it didn't:
|
| #include <stdlib.h>
| void *reachable;
| int main()
| {
| void *leaked = malloc(10);
| reachable = malloc(20);
| return 0;
| }
|
| $ gcc -g t.c && valgrind ./a.out
|
| ==13228== LEAK SUMMARY:
| *> ==13228== definitely lost: 10 bytes in 1 blocks.
| ==13228== possibly lost: 0 bytes in 0 blocks.
| *> ==13228== still reachable: 20 bytes in 1 blocks.
| ==13228== suppressed: 0 bytes in 0 blocks.
| ==13228== Use --leak-check=full to see details of leaked memory.
So one could make palloc() allocate 2 pieces of memory, the requested one,
and one that is added to a list anchored in global memory to hold the pointer
to the requested one. It should do this only when compiled with the symbol
__I_WILL_BE_RUNNING_THIS_UNDER_VALGRIND_NYAH_NYAH_NYAH__ :-)
--
|WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance |
| by the abuse department, bellsouth.net is blocked. If you post to |
| Usenet from these places, find another Usenet provider ASAP. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
.
- References:
- why no palloc() ("permanent alloc")?
- From: Bernie Ohls
- Re: why no palloc() ("permanent alloc")?
- From: Joachim Schmitz
- Re: why no palloc() ("permanent alloc")?
- From: phil-news-nospam
- Re: why no palloc() ("permanent alloc")?
- From: Joachim Schmitz
- Re: why no palloc() ("permanent alloc")?
- From: Joachim Schmitz
- Re: why no palloc() ("permanent alloc")?
- From: Barry Margolin
- Re: why no palloc() ("permanent alloc")?
- From: Paul Pluzhnikov
- why no palloc() ("permanent alloc")?
- Prev by Date: We have many new activities on the website. PayPal
- Next by Date: Re: files "." and ".." from readdir()
- Previous by thread: Re: why no palloc() ("permanent alloc")?
- Next by thread: Re: why no palloc() ("permanent alloc")?
- Index(es):
Relevant Pages
|