- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/modules/ke/src/ke_queue.c

Go to the documentation of this file.

    00001
    00021 /*
    00022  * INCLUDE FILES
    00023  ****************************************************************************************
    00024  */
    00025 #include <stddef.h>
    00026 #include "co_int.h"
    00027 #include "co_bool.h"
    00028 #include "dbg_assert.h"
    00029
    00030 #include "ke_config.h"
    00031 #include "ke_queue.h"
    00032 #include "ke_mem.h"
    00033
    00045 struct co_list_hdr *ke_queue_extract(struct co_list * const queue,
    00046                                  bool (*func)(struct co_list_hdr const * elmt, uint32_t arg),
    00047                                  uint32_t arg)
    00048 {
    00049     struct co_list_hdr *prev = NULL;
    00050     struct co_list_hdr *element  = queue->first;
    00051
    00052     while (element)
    00053     {
    00054         if (func(element, arg))
    00055         {
    00056             if (prev)
    00057             {
    00058                 // second or more
    00059                 prev->next = element->next;
    00060             }
    00061             else
    00062             {
    00063                 // first message
    00064                 queue->first = element->next;
    00065             }
    00066
    00067             if (element->next)
    00068             {
    00069                 // not the last
    00070                 element->next = NULL;
    00071             }
    00072             else
    00073             {
    00074                 // last message
    00075                 queue->last = prev;
    00076             }
    00077
    00078             break;
    00079         }
    00080
    00081         prev = element;
    00082         element = element->next;
    00083     }
    00084
    00085     #if KE_PROFILING
    00086     if(element != NULL)
    00087     {
    00088         queue->cnt--;
    00089         if(queue->mincnt > queue->cnt)
    00090         {
    00091             queue->mincnt = queue->cnt;
    00092         }
    00093     }
    00094     #endif //KE_PROFILING
    00095
    00096     return element;
    00097 }
    00098