summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-09 23:21:06 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-09-11 08:41:32 +0900
commitcd829bb078e6a3486d9b5ea57fc5111d289c1860 (patch)
treef1c903880d0ed454250f95d95a6e6d765a899796 /include
parent967b9743faac0b55a3d8deb176a08fdff449bba8 (diff)
Remove printf family from the mjit header
Linking printf family functions makes mjit objects to link unnecessary code.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4820
Diffstat (limited to 'include')
-rw-r--r--include/ruby/internal/core/rstring.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/include/ruby/internal/core/rstring.h b/include/ruby/internal/core/rstring.h
index e14753ab55..d16a57b1c4 100644
--- a/include/ruby/internal/core/rstring.h
+++ b/include/ruby/internal/core/rstring.h
@@ -371,6 +371,16 @@ void rb_check_safe_str(VALUE);
* only. You can safely forget about it.
*/
#define Check_SafeStr(v) rb_check_safe_str(RBIMPL_CAST((VALUE)(v)))
+
+/**
+ * @private
+ *
+ * Prints diagnostic message to stderr when RSTRING_PTR or RSTRING_END
+ * is NULL.
+ *
+ * @param[in] func The function name where encountered NULL pointer.
+ */
+void rb_debug_rstring_null_ptr(const char *func);
RBIMPL_SYMBOL_EXPORT_END()
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
@@ -476,12 +486,7 @@ RSTRING_PTR(VALUE str)
* Also, this is not rb_warn() because RSTRING_PTR() can be called
* during GC (see what obj_info() does). rb_warn() needs to allocate
* Ruby objects. That is not possible at this moment. */
- fprintf(stderr, "%s\n",
- "RSTRING_PTR is returning NULL!! "
- "SIGSEGV is highly expected to follow immediately. "
- "If you could reproduce, attach your debugger here, "
- "and look at the passed string."
- );
+ rb_debug_rstring_null_ptr("RSTRING_PTR");
}
return ptr;
@@ -502,12 +507,7 @@ RSTRING_END(VALUE str)
if (RB_UNLIKELY(! buf.as.heap.ptr)) {
/* Ditto. */
- fprintf(stderr, "%s\n",
- "RSTRING_END is returning NULL!! "
- "SIGSEGV is highly expected to follow immediately. "
- "If you could reproduce, attach your debugger here, "
- "and look at the passed string."
- );
+ rb_debug_rstring_null_ptr("RSTRING_END");
}
return &buf.as.heap.ptr[buf.as.heap.len];