Luna::intern_name

const c8 * intern_name(const c8 *name, usize count)

Interns one name string to the runtime and fetches the interned address for it.

Parameters

  • in name

    The name string to intern.

  • in count

    The number of characters that should be copied in name, excluding the null terminator if any.

Return value

Returns the interned address for the name string. If name is nullptr or size is 0, 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_namewith 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.