*/
xbt_fifo_t xbt_fifo_new(void)
{
- xbt_fifo_t fifo;
- fifo = xbt_new0(struct xbt_fifo, 1);
+ xbt_fifo_t fifo = xbt_new0(struct xbt_fifo, 1);
return fifo;
}
*/
xbt_fifo_item_t xbt_fifo_push(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t new;
-
- new = xbt_fifo_new_item();
+ xbt_fifo_item_t new = xbt_fifo_new_item();
new->content = t;
xbt_fifo_push_item(l, new);
*/
void *xbt_fifo_pop(xbt_fifo_t l)
{
- void *content;
-
if (l == NULL)
return NULL;
xbt_fifo_item_t item = xbt_fifo_pop_item(l);
if (!item)
return NULL;
- content = item->content;
+ void *content = item->content;
xbt_fifo_free_item(item);
return content;
}
*/
xbt_fifo_item_t xbt_fifo_unshift(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t new;
-
- new = xbt_fifo_new_item();
+ xbt_fifo_item_t new = xbt_fifo_new_item();
new->content = t;
xbt_fifo_unshift_item(l, new);
return new;
*/
void *xbt_fifo_shift(xbt_fifo_t l)
{
- void *content;
-
if (l == NULL)
return NULL;
xbt_fifo_item_t item = xbt_fifo_shift_item(l);
if (!item)
return NULL;
- content = item->content;
+ void *content = item->content;
xbt_fifo_free_item(item);
return content;
}
*/
xbt_fifo_item_t xbt_fifo_pop_item(xbt_fifo_t l)
{
- xbt_fifo_item_t item;
-
if (l->tail == NULL)
return NULL;
- item = l->tail;
+ xbt_fifo_item_t item = l->tail;
l->tail = item->prev;
if (l->tail == NULL)
new->next = l->head;
new->next->prev = new;
l->head = new;
- return;
}
/** Shift bucket
*/
xbt_fifo_item_t xbt_fifo_shift_item(xbt_fifo_t l)
{
- xbt_fifo_item_t item;
-
if (l->head == NULL)
return NULL;
- item = l->head;
+ xbt_fifo_item_t item = l->head;
l->head = item->next;
if (l->head == NULL)
*/
int xbt_fifo_remove(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t current, current_next;
+ xbt_fifo_item_t current;
+ xbt_fifo_item_t current_next;
for (current = l->head; current; current = current_next) {
current_next = current->next;
*/
int xbt_fifo_remove_all(xbt_fifo_t l, void *t)
{
- xbt_fifo_item_t current, current_next;
+ xbt_fifo_item_t current;
+ xbt_fifo_item_t current_next;
int res = 0;
for (current = l->head; current; current = current_next) {
*/
xbt_fifo_t xbt_fifo_copy(xbt_fifo_t f)
{
- xbt_fifo_t copy = NULL;
+ xbt_fifo_t copy = xbt_fifo_new();
xbt_fifo_item_t b;
- copy = xbt_fifo_new();
-
for (b = xbt_fifo_get_first_item(f); b; b = b->next) {
xbt_fifo_push(copy, b->content);
}
inline void xbt_fifo_free_item(xbt_fifo_item_t b)
{
xbt_mallocator_release(item_mallocator, b);
- return;
}
/** Destructor
{
XBT_CWARN(xbt_fifo, "This function is deprecated. Use xbt_fifo_free_item.");
xbt_fifo_free_item(b);
- return;
}
/**
* These are internal XBT functions called by xbt_preinit/postexit().
* It can be used several times to recreate the mallocator, for example when you switch to MC mode
*/
-void xbt_fifo_preinit(void)
+void xbt_fifo_preinit()
{
item_mallocator = xbt_mallocator_new(65536, fifo_item_mallocator_new_f,
fifo_item_mallocator_free_f, fifo_item_mallocator_reset_f);
}
-void xbt_fifo_postexit(void)
+void xbt_fifo_postexit()
{
if (item_mallocator != NULL) {
xbt_mallocator_free(item_mallocator);