Luna::intern_name
const c8 * intern_name(const c8 *name)
Interns one name string to the runtime and fetches the interned address for it.
Parameters
-
in name
The name string to intern.
Return value
Returns the interned address for the name string. If name
is nullptr
or points to an empty string (""
), the returned address is nullptr
and the memory block is not interned.
Remark
The name string is saved in the runtime and is reference counted. The first call to intern_name with a new string allocates the memory block to store the string and returns the block address. Additional calls to intern_name with the same string will only increase the reference count of the memory block and returns the same address, so the user can simply compares two address (pointer) to check if they refer to the same string.
For each call to intern_name, one call to release_name is needed to finally release the internal name string block.
For end user, prefer using Name objects instead of calling these APIs directly.
Valid Usage
- If
name
is notnullptr
, it must be ended with one null terminator.