#endif // _di_f_adjust_
-// the delete, destroy, resize, and adjust structure defines are mean to centralize allocation for all FLL structures that follow the size+used approach.
+// centralize allocation for all FLL structures that follow the size+used approach.
+#ifndef _di_f_clear_structure_
+ // structure: the structure to operate on
+ #define f_clear_structure(structure) \
+ structure.array = 0; \
+ structure.size = 0; \
+ structure.used = 0;
+#endif // _di_f_clear_structure_
+
+#ifndef _di_f_new_structure_
+ // status: the status to return
+ // structure: the structure to operate on
+ // type: the structure type
+ #define f_new_structure(status, structure, type, length) \
+ structure.array = 0; \
+ structure.size = 0; \
+ structure.used = 0; \
+ status = f_new_array((void **) & structure.array, sizeof(type), length); \
+ if (status == f_none) { \
+ structure.size = length; \
+ structure.used = 0; \
+ }
+#endif // _di_f_new_structure_
+
// improper use of these defines can lead to memory leaks and compilation errors
#ifndef _di_f_delete_structure_
// status: the status to return
}
#endif // _di_f_adjust_structure_
-// the delete, destroy, resize, and adjust structures defines function in the same way that the delete, destroy, resize, and adjust structure defines do
+// Structures defines function in the same way that the structure defines do
// however, these hold an array of structure
// improper use of these defines can lead to memory leaks and compilation errors
+#ifndef _di_f_clear_structures_
+ // structure: the structure to operate on
+ #define f_clear_structures(structures) \
+ structures.array = 0; \
+ structures.size = 0; \
+ structures.used = 0;
+#endif // _di_f_clear_structures_
+
+#ifndef _di_f_new_structures_
+ // status: the status to return
+ // structures: the structure to operate on
+ // type: the structure type
+ #define f_new_structures(status, structures, type, new_length) \
+ structures.array = 0; \
+ structures.size = 0; \
+ structures.used = 0; \
+ status = f_new_array((void **) & structures.array, sizeof(type), new_length); \
+ if (status == f_none) { \
+ structures.size = new_length; \
+ structures.used = 0; \
+ }
+#endif // _di_f_new_structures_
+
#ifndef _di_f_delete_structures_
// status: the status to return
// structures: the structure to operate on
#define f_string_length_printf string_format_long_integer
- #define f_new_string_length(status, string, length) status = f_new_array((f_void_p *) & string, sizeof(f_string_length), length)
- #define f_delete_string_length(status, string) status = f_delete((f_void_p *) & string)
- #define f_destroy_string_length(status, string, size) status = f_destroy((f_void_p *) & string, sizeof(f_string_length), size)
+ #define f_new_string_length(status, string, length) status = f_new_array((f_void_p *) & string, sizeof(f_string_length), length)
+ #define f_delete_string_length(status, string, length) status = f_delete((f_void_p *) & string, sizeof(f_string_length), length)
+ #define f_destroy_string_length(status, string, size) status = f_destroy((f_void_P *) & string, sizeof(f_string_length), size)
#define f_resize_string_length(status, length, old_length, new_length) \
status = f_resize((f_void_p *) & length, sizeof(f_string_length), old_length, new_length)
#define f_string_lengths_initialize { 0, 0, 0 }
+ #define f_new_string_lengths(status, lengths) \
+ f_new_structure(status, lengths, f_string_length)
+
#define f_delete_string_lengths(status, lengths) \
f_delete_structure(status, lengths, f_string_length)
#define f_string_locations_initialize {0, 0, 0}
+ #define f_clear_string_locations(locations) \
+ f_clear_structure(locations)
+
+ #define f_new_string_locations(status, locations, length) \
+ f_new_structure(status, locations, f_string_location, length)
+
#define f_delete_string_locations(status, locations) \
f_delete_structure(status, locations, f_string_location)
#define f_dynamic_string_initialize { f_string_initialize, 0, 0 }
+ #define f_clear_dynamic_string(dynamic) \
+ dynamic.string = f_null; \
+ dynamic.size = 0; \
+ dynamic.used = 0;
+
+ #define f_new_dynamic_string(status, dynamic, new_length) \
+ f_clear_dynamic_string(dynamic) \
+ status = f_new_array((void **) & dynamic.string, sizeof(f_string), new_length); \
+ if (status == f_none) { \
+ dynamic.size = new_length; \
+ dynamic.used = 0; \
+ }
+
#define f_delete_dynamic_string(status, dynamic) \
status = f_delete((f_void_p *) & dynamic.string, sizeof(f_string), dynamic.size); \
if (status == f_none) { \
#define f_dynamic_strings_initialize { 0, 0, 0 }
+ #define f_clear_dynamic_strings(dynamics) \
+ dynamics.array = 0; \
+ dynamics.size = 0; \
+ dynamics.used = 0;
+
+ #define f_new_dynamic_strings(status, dynamics, length) \
+ dynamics.array = 0; \
+ dynamics.size = 0; \
+ dynamics.used = 0; \
+ status = f_new_array((void **) & dynamics.array, sizeof(f_dynamic_string), length); \
+ if (status == f_none) { \
+ dynamics.size = length; \
+ dynamics.used = 0; \
+ }
+
#define f_delete_dynamic_strings(status, dynamics) \
status = f_none; \
while (dynamics.size > 0) { \
--dynamics.size; \
- f_delete_dynamic_string(status, dynamics.array[dynamics.size]); \
+ f_destroy_dynamic_string(status, dynamics.array[dynamics.size]); \
if (status != f_none) break; \
} \
if (status == f_none) status = f_delete((f_void_p *) & dynamics.array, sizeof(f_dynamic_string), dynamics.size); \
if (new_length < dynamics.size) { \
f_string_length i = dynamics.size - new_length; \
for (; i < dynamics.size; ++i) { \
- f_delete_dynamic_string(status, dynamics.array[i]); \
+ f_destroy_dynamic_string(status, dynamics.array[i]); \
if (status != f_none) break; \
} \
} \
if (new_length > dynamics.size) { \
f_string_length i = dynamics.size; \
for (; i < new_length; ++i) { \
- memset(&dynamics.array[i], 0, sizeof(f_string)); \
+ memset(&dynamics.array[i], 0, sizeof(f_dynamic_string)); \
} \
} \
dynamics.size = new_length; \
if (new_length < dynamics.size) { \
f_string_length i = dynamics.size - new_length; \
for (; i < dynamics.size; ++i) { \
- f_destroy_dynamic_string(status, dynamics.array[i]); \
+ f_destroy_dynamic_string(status, dynamics.array[i], f_dynamic_string); \
if (status != f_none) break; \
} \
} \