Skip to content

Commit d4c2ab4

Browse files
committed
Fix compilation errors related to tmpbuf
1 parent 50a4aa1 commit d4c2ab4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gc/default/default.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,7 +3033,8 @@ rb_mmtk_each_object_safe(void (*func)(VALUE, void *), void *data)
30333033
// We must not trigger GC while running `mmtk_enumerate_objects`,
30343034
// so we use `malloc` directly.
30353035
// It will be realloced as we add more objects.
3036-
VALUE *array = (VALUE*)malloc(sizeof(VALUE) * initial_capacity);
3036+
size_t array_bytes = sizeof(VALUE) * initial_capacity;
3037+
VALUE *array = (VALUE*)malloc(array_bytes);
30373038
struct rb_mmtk_build_obj_array_data build_array_data = {
30383039
.array_ptr = &array,
30393040
.len = 0,
@@ -3045,7 +3046,7 @@ rb_mmtk_each_object_safe(void (*func)(VALUE, void *), void *data)
30453046

30463047
// Root the array.
30473048
rb_imemo_tmpbuf_set_ptr(tmpbuf, array);
3048-
((rb_imemo_tmpbuf_t*)tmpbuf)->cnt = build_array_data.len;
3049+
((rb_imemo_tmpbuf_t*)tmpbuf)->size = array_bytes;
30493050
// GC is OK from now on.
30503051

30513052
// Inform the VM about malloc memory usage.
@@ -3076,7 +3077,7 @@ rb_mmtk_each_object_safe(void (*func)(VALUE, void *), void *data)
30763077
// Don't wait for GC to free it because `free()` is a bottleneck during GC.
30773078
// Adjust memory usage accordingly.
30783079
rb_imemo_tmpbuf_set_ptr(tmpbuf, NULL);
3079-
((rb_imemo_tmpbuf_t*)tmpbuf)->cnt = 0;
3080+
((rb_imemo_tmpbuf_t*)tmpbuf)->size = 0;
30803081
free(array);
30813082
rb_gc_adjust_memory_usage(-(ssize_t)(sizeof(VALUE) * build_array_data.capa));
30823083

0 commit comments

Comments
 (0)