From: Kevin Day Date: Thu, 1 Mar 2012 04:51:38 +0000 (-0600) Subject: Update: initialize string locations to {1, 0} X-Git-Tag: 0.3.x~16 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=90f872daead4904f99598fc10a2fad03ffd70fea;p=fll Update: initialize string locations to {1, 0} This is done so that the start position is always after the stop position. In such a case, this means that the range is undefined. Originally. -1 was used, but that does not work if the position integers are unsigned. Using {1, 0} allows for assigning an undefined state with unsigned integers. Also note that the default of {0, 0} means start at 0 and stop at 0, which would return the value at position 0 and no other values after that first value. --- diff --git a/level_0/f_strings/c/strings.h b/level_0/f_strings/c/strings.h index 15e1277..49d0c50 100644 --- a/level_0/f_strings/c/strings.h +++ b/level_0/f_strings/c/strings.h @@ -124,7 +124,7 @@ extern "C"{ f_string_length stop; } f_string_location; - #define f_string_location_initialize { f_string_length_initialize, f_string_length_initialize } + #define f_string_location_initialize { 1, 0 } #define f_new_string_location(status, string_location, length) status = f_new_array((void **) & string_location, sizeof(f_string_location), length) #define f_delete_string_location(status, string_location, size) status = f_delete((void **) & string_location, sizeof(f_string_location), size) diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index e7dafe4..6cf69b8 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -249,7 +249,8 @@ extern "C"{ { f_string_location input = f_string_location_initialize; - input.stop = data->buffer.used - 1; + input.start = 0; + input.stop = data->buffer.used - 1; status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents); } diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 2b36c73..eab6105 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -235,7 +235,8 @@ extern "C"{ { f_string_location input = f_string_location_initialize; - input.stop = data->buffer.used - 1; + input.start = 0; + input.stop = data->buffer.used - 1; status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents); } diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 611ca23..76eef84 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -247,7 +247,8 @@ extern "C"{ { f_string_location input = f_string_location_initialize; - input.stop = data->buffer.used - 1; + input.start = 0; + input.stop = data->buffer.used - 1; status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents); }