Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6192,6 +6192,21 @@ objspace_xfree(rb_objspace_t *objspace, void *ptr, size_t old_size)
objspace_malloc_increase(objspace, ptr, 0, old_size, MEMOP_TYPE_FREE);
}

void
ruby_memnotify(void *mem, size_t new_size, size_t old_size)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused a bit about this signature at first before reading the code. Guess it makes sense, but maybe good to document that behavior in a comment?

{
enum memop_type t;

if (new_size == 0)
t = MEMOP_TYPE_FREE;
else if (old_size == 0)
t = MEMOP_TYPE_MALLOC;
else
t = MEMOP_TYPE_REALLOC;

objspace_malloc_increase(&rb_objspace, mem, new_size, old_size, t);
}

void *
ruby_xmalloc(size_t size)
{
Expand Down
1 change: 1 addition & 0 deletions include/ruby/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ void *xcalloc(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
void *xrealloc(void*,size_t) RUBY_ATTR_ALLOC_SIZE((2));
void *xrealloc2(void*,size_t,size_t) RUBY_ATTR_ALLOC_SIZE((2,3));
void xfree(void*);
void ruby_memnotify(void*,size_t,size_t);

#define STRINGIZE(expr) STRINGIZE0(expr)
#ifndef STRINGIZE0
Expand Down