diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-04-15 11:48:11 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-04-15 11:48:11 +0900 |
| commit | 5944a31614279e814fff6a47d034f5c034226855 (patch) | |
| tree | dc9881da4da41069ae0dc8432fc49c515f243013 | |
| parent | 9a1c737deefc3f91473691fcb806a5b4aaf7716a (diff) | |
[DOC] Update sample callback of `rb_objspace_each_objects`
* refine liveness check
* fix missing closing brace
| -rw-r--r-- | gc.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -3944,14 +3944,16 @@ objspace_each_objects_try(VALUE arg) * * This is a sample callback code to iterate liveness objects: * - * int - * sample_callback(void *vstart, void *vend, int stride, void *data) { - * VALUE v = (VALUE)vstart; - * for (; v != (VALUE)vend; v += stride) { - * if (RBASIC(v)->flags) { // liveness check - * // do something with live object 'v' - * } - * return 0; // continue to iteration + * static int + * sample_callback(void *vstart, void *vend, int stride, void *data) + * { + * VALUE v = (VALUE)vstart; + * for (; v != (VALUE)vend; v += stride) { + * if (!rb_objspace_internal_object_p(v)) { // liveness check + * // do something with live object 'v' + * } + * } + * return 0; // continue to iteration * } * * Note: 'vstart' is not a top of heap_page. This point the first |
