Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/bdwgc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2017-05-22 09:06:24 +0300
committerIvan Maidanski <ivmai@mail.ru>2017-05-22 09:06:24 +0300
commit4982614d578bb3ae2924b78b07b1b722fbc27abc (patch)
tree3fd9c1eada2af4ac570330bdb16dbd8639bea7dc /doc
parentb810e8e0895cb6bc758bee23e913b9e64fb724a0 (diff)
Remove duplicated sample code in leak.md
* doc/leak.md (Example): Remove code snippets which are similar to that of include/leak_detector.h and leak_test.c; replace GC_find_leak=1 with GC_set_find_leak(1).
Diffstat (limited to 'doc')
-rw-r--r--doc/leak.md42
1 files changed, 6 insertions, 36 deletions
diff --git a/doc/leak.md b/doc/leak.md
index 9af33e87..e24652c4 100644
--- a/doc/leak.md
+++ b/doc/leak.md
@@ -65,45 +65,15 @@ the aid of a debugger.
## An Example
-The following header file `leak_detector.h` is included in the "include"
-subdirectory of the distribution:
-
-
- #define GC_DEBUG
- #include "gc.h"
- #define malloc(n) GC_MALLOC(n)
- #define calloc(m,n) GC_MALLOC((m)*(n))
- #define free(p) GC_FREE(p)
- #define realloc(p,n) GC_REALLOC((p),(n))
- #define CHECK_LEAKS() GC_gcollect()
-
+The `leak_detector.h` file is included in the "include" subdirectory of the
+distribution.
Assume the collector has been built with `-DFIND_LEAK`. (For newer versions
-of the collector, we could instead add the statement `GC_find_leak = 1` as the
-first statement in `main`.
-
-The program to be tested for leaks can then look like:
-
-
- #include "leak_detector.h"
-
- main() {
- int *p[10];
- int i;
- /* GC_find_leak = 1; for new collector versions not */
- /* compiled with -DFIND_LEAK. */
- for (i = 0; i < 10; ++i) {
- p[i] = malloc(sizeof(int)+i);
- }
- for (i = 1; i < 10; ++i) {
- free(p[i]);
- }
- for (i = 0; i < 9; ++i) {
- p[i] = malloc(sizeof(int)+i);
- }
- CHECK_LEAKS();
- }
+of the collector, we could instead add the statement `GC_set_find_leak(1)` as
+the first statement in `main`.
+The program to be tested for leaks can then look like "leak_test.c" file
+in the "tests" subdirectory of the distribution.
On an Intel X86 Linux system this produces on the stderr stream: