#endif // _di_f_string_ranges_
/**
- * A string that supports contains a size attribute to handle dynamic allocations and deallocations.
+ * A string that is analogous to f_string_dynamic but intended for static-only uses.
*
- * Save the string size along with the string, so that strlen(..) commands can be avoided as much as possible.
+ * The f_string_static type should never be directly allocated or deallocated.
*
* string: the string.
- * size: total amount of allocated space.
- * used: total number of allocated spaces used.
+ * size: total amount of space available.
+ * used: total number of space used.
*/
-#ifndef _di_f_string_dynamic_
+#ifndef _di_f_string_static_
typedef struct {
f_string string;
f_string_length size;
f_string_length used;
- } f_string_dynamic;
+ } f_string_static;
- #define f_string_dynamic_initialize { f_string_initialize, 0, 0 }
+ #define f_string_static_initialize { 0, 0, 0 }
- #define f_macro_string_dynamic_clear(dynamic) \
- dynamic.string = 0; \
- dynamic.size = 0; \
- dynamic.used = 0;
+ #define f_macro_string_static_clear(string_static) \
+ string_static.string = 0; \
+ string_static.size = 0; \
+ string_static.used = 0;
+#endif // _di_f_string_static_
+
+/**
+ * A string that supports contains a size attribute to handle dynamic allocations and deallocations.
+ *
+ * Save the string size along with the string, so that strlen(..) commands can be avoided as much as possible.
+ *
+ * This is a sub-type of f_string_static, allowing it to be passed into any f_string_static type.
+ * It is recommended that f_string_static are not otherwise casted into f_string_dynamic to avoid potential memory allocation issues.
+ *
+ * string: the string.
+ * size: total amount of allocated space.
+ * used: total number of allocated spaces used.
+ */
+#ifndef _di_f_string_dynamic_
+ typedef f_string_static f_string_dynamic;
+
+ #define f_string_dynamic_initialize f_string_static_initialize
+
+ #define f_macro_string_dynamic_clear(dynamic) f_macro_string_static_clear(dynamic)
#define f_macro_string_dynamic_new(status, dynamic, new_length) \
f_macro_string_dynamic_clear(dynamic) \