File: deallocation_pointer_validation.dox

package info (click to toggle)
libcwd 1.0.4-1.1
  • links: PTS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 8,136 kB
  • ctags: 10,313
  • sloc: cpp: 23,354; sh: 9,798; ansic: 1,172; makefile: 852; exp: 234; awk: 11
file content (51 lines) | stat: -rw-r--r-- 1,863 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*!
\defgroup chapter_validation De-Allocation Pointer Validation
\ingroup book_allocations
*/
/*!
\page page_validation
\ingroup chapter_validation

A pointer passed to a de-allocation (or re-allocation) function is checked to be valid;
it should be previously returned by a corresponding (re-)allocation function and not
have been de-allocated before. 
Table 1. shows the relationships between allocation and de-allocation functions.

\htmlonly
<h5 ALIGN=CENTER>Table 1. De-allocation functions and their corresponding allocation functions</h5>
<center>
<table BGCOLOR=Wheat BORDERCOLOR=#503c2c WIDTH=577 BORDER=1 CELLPADDING=4 CELLSPACING=0>
<tr>
<td BGCOLOR="#a98061"><font COLOR="#ffffff">De- or re-allocation function</font></td>
<td BGCOLOR="#a98061"><font COLOR="#ffffff">Allocation function</font></td>
</tr>
<tr>
<td><CODE>delete</CODE></td>
<td><CODE>new</CODE></td>
</tr>
<tr>
<td><CODE>delete&nbsp;[]</CODE></td>
<td><CODE>new&nbsp;[]</CODE></td>
</tr>
<tr>
<td><CODE>free()</CODE></td>
<td><CODE>malloc()</CODE>, <CODE>calloc()</CODE> or <CODE>realloc()</CODE></td>
</tr>
<tr>
<td><CODE>realloc()</CODE></td>
<td><CODE>malloc()</CODE>, <CODE>calloc()</CODE> or <CODE>realloc()</CODE></td>
</tr>
</table>
</center>
\endhtmlonly

The application will terminate with an informative message and a core dump when
a pointer is de-allocated that was not previously allocated with the corresponding allocation function.

Note: When libcwd was configured with \link enable_magic --disable-magic \endlink
then the check whether or not the de-allocated memory block was allocated with the corresponding
allocation function is \em not performed when the memory block is \ref group_invisible "invisible".&nbsp;
The reason for this is that invisible memory blocks are simply not stored in the internal data structure:
No information is known about them.

*/