summaryrefslogtreecommitdiff
path: root/ext/-test-/struct/duplicate.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/-test-/struct/duplicate.c')
-rw-r--r--ext/-test-/struct/duplicate.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/ext/-test-/struct/duplicate.c b/ext/-test-/struct/duplicate.c
new file mode 100644
index 0000000..596d32a
--- /dev/null
+++ b/ext/-test-/struct/duplicate.c
@@ -0,0 +1,24 @@
+#include "ruby.h"
+
+static VALUE
+bug_struct_new_duplicate(VALUE obj, VALUE name, VALUE mem)
+{
+ const char *n = NIL_P(name) ? 0 : StringValueCStr(name);
+ const char *m = StringValueCStr(mem);
+ return rb_struct_define(n, m, m, NULL);
+}
+
+static VALUE
+bug_struct_new_duplicate_under(VALUE obj, VALUE name, VALUE mem)
+{
+ const char *n = StringValueCStr(name);
+ const char *m = StringValueCStr(mem);
+ return rb_struct_define_under(obj, n, m, m, NULL);
+}
+
+void
+Init_duplicate(VALUE klass)
+{
+ rb_define_singleton_method(klass, "new_duplicate", bug_struct_new_duplicate, 2);
+ rb_define_singleton_method(klass, "new_duplicate_under", bug_struct_new_duplicate_under, 2);
+}