remove one nested function from nptl/allocatestack.c
Commit Message
Please review a patch to remove the use of a nested function.
No functionality change intended.
The removal of nested functions was previously discussed here:
https://sourceware.org/ml/libc-alpha/2014-05/msg00400.html
2014-06-04 Kostya Serebryany <konstantin.s.serebryany@gmail.com>
* nptl/allocatestack.c (check_list): New function.
(__reclaim_stacks): Remove the nested check_list function,
and use the static check_list instead.
Comments
That is fine, though it wouldn't hurt to improve the commentary and use
bool while you're there.
@@ -809,6 +809,24 @@ __make_stacks_executable (void **stack_endp)
return err;
}
+/* We always add at the beginning of the list. So in this
+ case we only need to check the beginning of these lists. */
+static int
+check_list (list_t *l, list_t *elem)
+{
+ if (l->next->prev != l)
+ {
+ assert (l->next->prev == elem);
+
+ elem->next = l->next;
+ elem->prev = l;
+ l->next = elem;
+
+ return 1;
+ }
+
+ return 0;
+}
/* In case of a fork() call the memory allocation in the child will be
the same but only one thread is running. All stacks except that of
@@ -830,26 +848,8 @@ __reclaim_stacks (void)
if (add_p)
{
- /* We always add at the beginning of the list. So in this
- case we only need to check the beginning of these lists. */
- int check_list (list_t *l)
- {
- if (l->next->prev != l)
- {
- assert (l->next->prev == elem);
-
- elem->next = l->next;
- elem->prev = l;
- l->next = elem;
-
- return 1;
- }
-
- return 0;
- }
-
- if (check_list (&stack_used) == 0)
- (void) check_list (&stack_cache);
+ if (check_list (&stack_used, elem) == 0)
+ (void) check_list (&stack_cache, elem);
}
else
{