Port the examples to rename _get_at to _safe_get
This commit is contained in:
1 parent
51d4e930f5
commit
c96cea5a13
3 files changed
+4
-4
No files matched your search
+1
-1
@@ -34,7 +34,7 @@ int main(int argc, const char *argv[])
|
|||||||
// While it reads some word from the file
|
// While it reads some word from the file
|
||||||
while (string_fget_word(word, " \t\n\r\"(),=", f)) {
|
while (string_fget_word(word, " \t\n\r\"(),=", f)) {
|
||||||
// Get the reference to the array of this word in the dictionnary (or create it if needed)
|
// Get the reference to the array of this word in the dictionnary (or create it if needed)
|
||||||
array_size_t *array = map_pos_get_at(positions, word);
|
array_size_t *array = map_pos_safe_get(positions, word);
|
||||||
// Push the new offset to this word in the associated array
|
// Push the new offset to this word in the associated array
|
||||||
array_size_push_back(*array, (size_t)ftell(f) - string_size(word));
|
array_size_push_back(*array, (size_t)ftell(f) - string_size(word));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ static void program_init(program_t p, string_t text) {
|
|||||||
int left;
|
int left;
|
||||||
array_int_pop_back(&left, leftstack);
|
array_int_pop_back(&left, leftstack);
|
||||||
int right = pc;
|
int right = pc;
|
||||||
*array_int_get_at (p->bracket_map, left) = right;
|
*array_int_safe_get (p->bracket_map, left) = right;
|
||||||
*array_int_get_at (p->bracket_map, right) = left;
|
*array_int_safe_get (p->bracket_map, right) = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
pc++;
|
pc++;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ int main(void)
|
|||||||
M_LET(map, dict_str_t) {
|
M_LET(map, dict_str_t) {
|
||||||
// Count the words:
|
// Count the words:
|
||||||
for M_EACH(w, words, vector_str_t) {
|
for M_EACH(w, words, vector_str_t) {
|
||||||
(*dict_str_get_at(map, *w)) ++;
|
(*dict_str_safe_get(map, *w)) ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the count:
|
// Print the count:
|
||||||
|
|||||||
Reference in new issue
Block a user