From 90f872daead4904f99598fc10a2fad03ffd70fea Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 29 Feb 2012 22:51:38 -0600 Subject: [PATCH] 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. --- level_0/f_strings/c/strings.h | 2 +- level_3/fss_basic_list_read/c/fss_basic_list_read.c | 3 ++- level_3/fss_basic_read/c/fss_basic_read.c | 3 ++- level_3/fss_extended_read/c/fss_extended_read.c | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) 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); } -- 1.8.3.1