atom.h
Include dependency graph for atom.h:
This graph shows which files directly or indirectly include atom.h:
Atoms manipulation functions.
This header provides atom manipulation functions, such as atom_string_len, atom_string_data, etc…
Defines
-
ATOM_STR(LENSTR, STR) (LENSTR STR)
No-op macro: just syntax sugar for avoiding mistakes or clang-format dividing atoms in multiple lines. Usage: ATOM_STR(“\x5”, “hello”).
Typedefs
-
typedef const void *AtomString
Functions
-
void atom_string_to_c(AtomString atom_string, char *buf, size_t bufsize)
Gets a C string from an AtomString.
Copies the atom string data to a buffer and makes it null terminated.
- Parameters:
atom_string – that will be converted to a C string.
buf – the buffer where the C string will be written.
bufsize – available buf size.
-
int atom_are_equals(AtomString a, AtomString b)
Check for equality two AtomStrings.
Returns 1 if two atom strings are equal, 0 otherwise. This function doesn’t behave like strcmp.
- Parameters:
a – first atom string to be compared.
b – second atom string to be compared.
- Returns:
1 if they are equals, 0 otherwise.
-
static inline size_t atom_string_len(AtomString atom_str)
Returns the length of an atom string in bytes.
Returns the length stored in the AtomString (which means that length is not computed).
- Parameters:
atom_str – the atom string.
- Returns:
the specified atom string length.
-
static inline const void *atom_string_data(AtomString atom_str)
Gets actual atom string data.
Returns actual atom string data, which is not a \0 terminated C string.
- Parameters:
atom_str – an AtomString pointer.
- Returns:
const pointer to string data (chars array).
-
void atom_write_mfa(char *buf, size_t buf_size, AtomString module, AtomString function, unsigned int arity)
Write module:function/arity to the supplied buffer.
Write module:function/arity to the supplied buffer. This function will abort if the written module, function, and arity are longer than the supplied buffer size.
- Parameters:
buf – the buffer to write into
buf_size – the amount of room in the buffer
module – the module name
function – the function name
arity – the function arity