-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more items to errata and fixed some listings
- Loading branch information
Showing
4 changed files
with
342 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
int list_sum( const struct list* l ) { | ||
int list_sum_bad( const struct list* l ) { | ||
size_t i; | ||
int sum = 0; | ||
/* We do not want to launch the full computation | ||
* of size at each cycle iteration */ | ||
size_t sz = list_size( l ) ; | ||
size_t sz = list_size( l ); | ||
for( i = 0; i < sz; l = l-> next ) | ||
sum = sum + l->value; | ||
sum = sum + list_get( l, i ); | ||
return sum; | ||
} | ||
|
||
int list_sum_good( const struct list* l ) { | ||
size_t i; | ||
int sum = 0; | ||
/* We do not want to launch the full computation | ||
* of size at each cycle iteration */ | ||
size_t sz = list_size( l ) ; | ||
for( i = 0; i < sz; l = l-> next ) | ||
sum = sum + l->value; | ||
return sum; | ||
} |
Oops, something went wrong.