From: kevin day Date: Sun, 4 Mar 2012 01:31:14 +0000 (-0600) Subject: Update: relocate the 'strategy' variable X-Git-Tag: 0.3.x~12 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=bf79997c5f5379e08fc709e4d200a1c371be9ad8;p=fll Update: relocate the 'strategy' variable Why waste space by putting the strategy in every variable. Sure it can be very convenient and is probably a good object-oriented approach, but favor simplicity in this the variable typedef. The cost of doing this is making the function call less simple by adding an additional parameter. --- diff --git a/level_0/f_serialized/c/serialized.h b/level_0/f_serialized/c/serialized.h index 6c129b9..aab4407 100644 --- a/level_0/f_serialized/c/serialized.h +++ b/level_0/f_serialized/c/serialized.h @@ -47,10 +47,9 @@ extern "C"{ f_string_length size; // total amount of allocated space f_string_length used; // total number of allocated spaces used f_array_length variables; // total number of serialized variables stored - f_u_short strategy, // serialized strategy in use } f_serialized; - #define f_serialized_initialize { f_string_initialize, f_string_length_initialize, f_string_length_initialize, f_array_length_initialize, 0 } + #define f_serialized_initialize { f_string_initialize, f_string_length_initialize, f_string_length_initialize, f_array_length_initialize } #define f_delete_serialized(status, serialized) \ status = f_delete((void **) & serialized.string, sizeof(f_string), serialized.size); \ diff --git a/level_1/fl_serialized/c/serialized.c b/level_1/fl_serialized/c/serialized.c index dbaa170..cb13514 100644 --- a/level_1/fl_serialized/c/serialized.c +++ b/level_1/fl_serialized/c/serialized.c @@ -11,12 +11,12 @@ extern "C" { #endif #ifndef _di_fl_serialize_ - f_return_status fl_serialize(const f_dynamic_string value, f_serialized *serialized) { + f_return_status fl_serialize(const f_u_short strategy, const f_dynamic_string value, f_serialized *serialized) { #ifndef _di_level_0_parameter_checking_ if (serialized == f_null) return f_invalid_parameter; #endif // _di_level_0_parameter_checking_ - if (serialized.strategy != f_serialized_strategy_simple) { + if (strategy != f_serialized_strategy_simple) { return f_unsupported; } @@ -37,13 +37,13 @@ extern "C" { #endif // _di_fl_serialize_ #ifndef _di_fl_unserialize_ - f_return_status fl_unserialize(const f_serialized *serialized, f_string_locations *locations) { + f_return_status fl_unserialize(const f_u_short strategy, const f_serialized *serialized, f_string_locations *locations) { #ifndef _di_level_0_parameter_checking_ if (serialized == f_null) return f_invalid_parameter; if (locations == f_null) return f_invalid_parameter; #endif // _di_level_0_parameter_checking_ - if (serialized.strategy != f_serialized_strategy_simple) { + if (strategy != f_serialized_strategy_simple) { return f_unsupported; } @@ -91,13 +91,13 @@ extern "C" { #endif // _di_fl_unserialize_ #ifndef _di_fl_unserialize_get_ - f_return_status fl_unserialize_get(const f_serialized serialized, const f_array_length index, f_string_location *location) { + f_return_status fl_unserialize_get(const f_u_short strategy, const f_serialized serialized, const f_array_length index, f_string_location *location) { #ifndef _di_level_0_parameter_checking_ if (serialized == f_null) return f_invalid_parameter; if (location == f_null) return f_invalid_parameter; #endif // _di_level_0_parameter_checking_ - if (serialized.strategy != f_serialized_strategy_simple) { + if (strategy != f_serialized_strategy_simple) { return f_unsupported; } diff --git a/level_1/fl_serialized/c/serialized.h b/level_1/fl_serialized/c/serialized.h index 73a93f8..978b0f2 100644 --- a/level_1/fl_serialized/c/serialized.h +++ b/level_1/fl_serialized/c/serialized.h @@ -27,17 +27,17 @@ extern "C" { #ifndef _di_fl_serialize_ // this function will append a string to the serialize. - extern f_return_status fl_serialize(const f_dynamic_string value, f_serialized *serialized); + extern f_return_status fl_serialize(const f_u_short strategy, const f_dynamic_string value, f_serialized *serialized); #endif // _di_fl_serialize_ #ifndef _di_fl_unserialize_ // this function will unserialize a serialized string and store the results in an array of strings. - extern f_return_status fl_unserialize(const f_serialized serialized, f_string_locations *locations); + extern f_return_status fl_unserialize(const f_u_short strategy, const f_serialized serialized, f_string_locations *locations); #endif // _di_fl_unserialize_ #ifndef _di_fl_unserialize_get_ // this function will pull a single serialized value from the serialized string at the given index. - extern f_return_status fl_unserialize_get(const f_serialized serialized, const f_array_length index, f_string_location *location); + extern f_return_status fl_unserialize_get(const f_u_short strategy, const f_serialized serialized, const f_array_length index, f_string_location *location); #endif // _di_fl_unserialize_get_ #ifdef __cplusplus