rb_bug if rb_gc_impl_active_gc_name is too long
This avoids the need to malloc, and reduces the complexity of truncating the long string for display in RUBY_DESCRIPTION. The developer of a GC implementation should be responsible for giving it a succinct name.
This commit is contained in:
parent
ee290c94a3
commit
6795fc4981
Notes:
git
2024-11-14 10:46:54 +00:00
9
gc.c
9
gc.c
@ -2780,13 +2780,8 @@ rb_gc_active_gc_name(void)
|
||||
{
|
||||
const char *gc_name = rb_gc_impl_active_gc_name();
|
||||
if (strlen(gc_name) > RB_GC_MAX_NAME_LEN) {
|
||||
char *truncated_gc_name = ruby_xmalloc(RB_GC_MAX_NAME_LEN + 1);
|
||||
|
||||
rb_warn("GC module %s has a name larger than %d chars, it will be truncated\n",
|
||||
gc_name, RB_GC_MAX_NAME_LEN);
|
||||
|
||||
strncpy(truncated_gc_name, gc_name, RB_GC_MAX_NAME_LEN);
|
||||
return (const char *)truncated_gc_name;
|
||||
rb_bug("GC should have a name shorter than %d chars. Currently: %lu (%s)\n",
|
||||
RB_GC_MAX_NAME_LEN, strlen(gc_name), gc_name);
|
||||
}
|
||||
return gc_name;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user