-
|
Can you explain these macros ? #define StringZ(Z) {sizeof(Z) - 1, (u8 *)(Z)}
#define StringZFunc(Z) BundleString(sizeof(Z) - 1, (Z)) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Yes, those functions are basically initializing the string (alias buffer) struct without copying anything. typedef struct buffer
{
umw Count; // strength length
u8* Data; // the string data
} buffer, string;StringZ is creating the struct initialization at compile time. This should only be used for literals. I am actually going to rename this now to make it clearer. Both simply take a string argument. One should be used for literals while the other could be used for runtime strings. The Z in the name is to indicate that it handles zero-terminated strings, that means a string that is terminated C-style with a null at the end The length that is calculated is the logical length. |
Beta Was this translation helpful? Give feedback.
Yes, those functions are basically initializing the string (alias buffer) struct without copying anything.
So, this:
StringZ is creating the struct initialization at compile time. This should only be used for literals. I am actually going to rename this now to make it clearer.
StringZFunc creates it at runtime because there is a function call happening.
Both simply take a string argument. One should be used for literals while the other could be used for runtime strings.
The Z in the name is to indicate that it handles zero-terminated strings, that means a string that is termin…