core :: FlatText :: fast_cstring
first_byte
WARNING: If you choose to use this service, be careful of the following.
Strings and CString are ideally always allocated through a Garbage Collector. Since the GC tracks the use of the pointer for the beginning of the char*, it may be deallocated at any moment, rendering the pointer returned by this function invalid. Any access to freed memory may very likely cause undefined behaviour or a crash. (Failure to do so will most certainly result in long and painful debugging hours)
The only safe use of this pointer is if it is ephemeral (e.g. read in a C function then immediately return).
As always, do not modify the content of the String in C code, if this is what you want copy locally the char* as Nit Strings are immutable.
# Returns a char* starting at position `first_byte`
#
# WARNING: If you choose to use this service, be careful of the following.
#
# Strings and CString are *ideally* always allocated through a Garbage Collector.
# Since the GC tracks the use of the pointer for the beginning of the char*, it may be
# deallocated at any moment, rendering the pointer returned by this function invalid.
# Any access to freed memory may very likely cause undefined behaviour or a crash.
# (Failure to do so will most certainly result in long and painful debugging hours)
#
# The only safe use of this pointer is if it is ephemeral (e.g. read in a C function
# then immediately return).
#
# As always, do not modify the content of the String in C code, if this is what you want
# copy locally the char* as Nit Strings are immutable.
fun fast_cstring: CString is abstract
lib/core/text/abstract_text.nit:1410,2--1425,38
redef fun fast_cstring do return _items.fast_cstring(_first_byte)
lib/core/text/flat.nit:440,2--66
redef fun fast_cstring do return _items.fast_cstring(0)
lib/core/text/flat.nit:876,2--56