* lib/commonio.c: Avoid pre-decrement operator (--n). Add some
comments. * libmisc/cleanup.c: Fix off by one in an assertion.
This commit is contained in:
parent
a845c67c60
commit
1e51ab0b23
@ -1,3 +1,9 @@
|
|||||||
|
2009-09-08 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/commonio.c: Avoid pre-decrement operator (--n). Add some
|
||||||
|
comments.
|
||||||
|
* libmisc/cleanup.c: Fix off by one in an assertion.
|
||||||
|
|
||||||
2009-09-08 Nicolas François <nicolas.francois@centraliens.net>
|
2009-09-08 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/su.c: Fix indentation.
|
* src/su.c: Fix indentation.
|
||||||
|
@ -703,13 +703,16 @@ commonio_sort (struct commonio_db *db, int (*cmp) (const void *, const void *))
|
|||||||
}
|
}
|
||||||
qsort (entries, n, sizeof (struct commonio_entry *), cmp);
|
qsort (entries, n, sizeof (struct commonio_entry *), cmp);
|
||||||
|
|
||||||
|
/* Take care of the head and tail separately */
|
||||||
db->head = entries[0];
|
db->head = entries[0];
|
||||||
db->tail = entries[--n];
|
n--;
|
||||||
|
db->tail = entries[n];
|
||||||
db->head->prev = NULL;
|
db->head->prev = NULL;
|
||||||
db->head->next = entries[1];
|
db->head->next = entries[1];
|
||||||
db->tail->prev = entries[n - 1];
|
db->tail->prev = entries[n - 1];
|
||||||
db->tail->next = NULL;
|
db->tail->next = NULL;
|
||||||
|
|
||||||
|
/* Now other elements have prev and next entries */
|
||||||
for (i = 1; i < n; i++) {
|
for (i = 1; i < n; i++) {
|
||||||
entries[i]->prev = entries[i - 1];
|
entries[i]->prev = entries[i - 1];
|
||||||
entries[i]->next = entries[i + 1];
|
entries[i]->next = entries[i + 1];
|
||||||
|
@ -109,7 +109,8 @@ void del_cleanup (cleanup_function pcf)
|
|||||||
/* Move the rest of the cleanup functions */
|
/* Move the rest of the cleanup functions */
|
||||||
for (; i<CLEANUP_FUNCTIONS; i++) {
|
for (; i<CLEANUP_FUNCTIONS; i++) {
|
||||||
/* Make sure the cleanup function was specified only once */
|
/* Make sure the cleanup function was specified only once */
|
||||||
assert (cleanup_functions[i+1] != pcf);
|
assert ( (i == (CLEANUP_FUNCTIONS -1))
|
||||||
|
|| (cleanup_functions[i+1] != pcf));
|
||||||
|
|
||||||
if (i == (CLEANUP_FUNCTIONS -1)) {
|
if (i == (CLEANUP_FUNCTIONS -1)) {
|
||||||
cleanup_functions[i] = NULL;
|
cleanup_functions[i] = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user