-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest005.cc
More file actions
34 lines (31 loc) · 1.13 KB
/
test005.cc
File metadata and controls
34 lines (31 loc) · 1.13 KB
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
#include "dmalloc.hh"
#include <cstdio>
#include <cassert>
#include <cinttypes>
// Failed allocation.
int main() {
void* ptrs[10];
for (int i = 0; i != 10; ++i) {
ptrs[i] = malloc(i + 1);
}
for (int i = 0; i != 5; ++i) {
free(ptrs[i]);
}
size_t very_large_size = (size_t) -1 - 150;
void* garbage = malloc(very_large_size);
assert(!garbage);
dmalloc_print_statistics();
}
// The text within ??{...}?? pairs is a REGULAR EXPRESSION.
// (Some sites about regular expressions:
// http://www.lornajane.net/posts/2011/simple-regular-expressions-by-example
// https://www.icewarp.com/support/online_help/203030104.htm
// http://xkcd.com/208/
// Dig deeper into how regular expresisons are implemented:
// http://swtch.com/~rsc/regexp/regexp1.html )
// This particular regular expression lets our check work correctly on both
// 32-bit and 64-bit architectures. It checks for a `fail_size` of either
// 2^32 - 151 or 2^64 - 151.
//! ???
//! alloc count: active 5 total 10 fail 1
//! alloc size: active ??? total 55 fail ??{4294967145|18446744073709551465}??