10 changed files with 70 additions and 263 deletions
-
27include/tr/queue.h
-
7src/queue/Makefile.am
-
49src/queue/delete.c
-
48src/queue/destroy.c
-
36src/queue/find.c
-
36src/queue/find_parent.c
-
20src/queue/get.c
-
45src/queue/put.c
-
40src/queue/put_first.c
-
17src/queue/queue.c
@ -1,49 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
#include "tr/queue.h" |
|
||||
|
|
||||
void |
|
||||
TR_queueDelete(TR_Queue this, void * msg) |
|
||||
{ |
|
||||
TR_Queue node, parent; |
|
||||
|
|
||||
parent = TR_queueFindParent(this, msg); |
|
||||
|
|
||||
if (! parent) { |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
node = parent->next; |
|
||||
parent->next = node->next; |
|
||||
if (node == this->last) { |
|
||||
this->last = parent; |
|
||||
} |
|
||||
if (node == this->first) { |
|
||||
this->first = node->next; |
|
||||
} |
|
||||
TR_delete(node); |
|
||||
this->nmsg--; |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
@ -1,48 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include <stdarg.h> |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
#include "tr/queue.h" |
|
||||
|
|
||||
void |
|
||||
TR_queueDestroy(TR_Queue this) |
|
||||
{ |
|
||||
TR_Queue node; |
|
||||
|
|
||||
node = this->first; |
|
||||
|
|
||||
while (NULL != node) { |
|
||||
TR_Queue next = node->next; |
|
||||
if (this->free_msgs) { |
|
||||
TR_delete(node->msg); |
|
||||
} |
|
||||
TR_delete(node); |
|
||||
node = next; |
|
||||
} |
|
||||
|
|
||||
this->first = this->next = this->last = NULL; |
|
||||
this->nmsg = 0; |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
@ -1,36 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
#include "tr/queue.h" |
|
||||
|
|
||||
TR_Queue |
|
||||
TR_queueFind(TR_Queue this, void * msg) |
|
||||
{ |
|
||||
TR_Queue node; |
|
||||
|
|
||||
for (node = this->first; node && node->msg != msg; node = node->next); |
|
||||
|
|
||||
return node; |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
@ -1,36 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
#include "tr/queue.h" |
|
||||
|
|
||||
TR_Queue |
|
||||
TR_queueFindParent(TR_Queue this, void * msg) |
|
||||
{ |
|
||||
TR_Queue node; |
|
||||
|
|
||||
for (node = this; node->next && node->next->msg != msg; node = node->next); |
|
||||
|
|
||||
return node->next ? node : NULL; |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
@ -1,40 +0,0 @@ |
|||||
/** |
|
||||
* \file |
|
||||
* |
|
||||
* \author Georg Hopp |
|
||||
* |
|
||||
* \copyright |
|
||||
* Copyright © 2014 Georg Hopp |
|
||||
* |
|
||||
* This program is free software: you can redistribute it and/or modify |
|
||||
* it under the terms of the GNU General Public License as published by |
|
||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||
* (at your option) any later version. |
|
||||
* |
|
||||
* This program is distributed in the hope that it will be useful, |
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
* GNU General Public License for more details. |
|
||||
* |
|
||||
* You should have received a copy of the GNU General Public License |
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
*/ |
|
||||
|
|
||||
#include "trbase.h" |
|
||||
#include "tr/queue.h" |
|
||||
|
|
||||
void |
|
||||
TR_queuePutFirst(TR_Queue this, void * msg) |
|
||||
{ |
|
||||
TR_Queue current_first; |
|
||||
|
|
||||
current_first = this->first; |
|
||||
|
|
||||
this->first = this->next = TR_new(TR_Queue); |
|
||||
this->first->next = current_first; |
|
||||
this->first->msg = msg; |
|
||||
this->last = this->last ? this->last : this->first; |
|
||||
this->nmsg++; |
|
||||
} |
|
||||
|
|
||||
// vim: set ts=4 sw=4: |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue