Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b49af6e authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "cutils: only support safe list iteration." am: 52a21351 am:...

Merge "cutils: only support safe list iteration." am: 52a21351 am: 9c0b1f43 am: 5e74c2e9 am: 3346d8ba

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1879198

Change-Id: If38ae77c0eb3c61ac557d69ee34e83903be84247
parents c6806731 3346d8ba
Loading
Loading
Loading
Loading
+6 −8
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2008-2013 The Android Open Source Project
 * Copyright (C) 2008 The Android Open Source Project
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -14,8 +14,7 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#ifndef _CUTILS_LIST_H_
#pragma once
#define _CUTILS_LIST_H_


#include <stddef.h>
#include <stddef.h>


@@ -38,9 +37,6 @@ struct listnode
        .prev = &(name), \
        .prev = &(name), \
    }
    }


#define list_for_each(node, list) \
    for ((node) = (list)->next; (node) != (list); (node) = (node)->next)

#define list_for_each_reverse(node, list) \
#define list_for_each_reverse(node, list) \
    for ((node) = (list)->prev; (node) != (list); (node) = (node)->prev)
    for ((node) = (list)->prev; (node) != (list); (node) = (node)->prev)


@@ -49,6 +45,10 @@ struct listnode
         (node) != (list); \
         (node) != (list); \
         (node) = (n), (n) = (node)->next)
         (node) = (n), (n) = (node)->next)


#define list_for_each(node, list)                                                \
    for (struct listnode* __n = ((node) = (list)->next)->next; (node) != (list); \
         (node) = __n, __n = (node)->next)

static inline void list_init(struct listnode *node)
static inline void list_init(struct listnode *node)
{
{
    node->next = node;
    node->next = node;
@@ -84,5 +84,3 @@ static inline void list_remove(struct listnode *item)
#ifdef __cplusplus
#ifdef __cplusplus
};
};
#endif /* __cplusplus */
#endif /* __cplusplus */

#endif