Commit 96d30bb5f31aebecbfea377e45ab4da474837fa2

Authored by Georg Hopp
1 parent 28134883

add more list like functions to the queue .. they are not used now and not teste…

…s, so they probably have bugs.
@@ -39,4 +39,4 @@ gmon.out @@ -39,4 +39,4 @@ gmon.out
39 test-driver 39 test-driver
40 /assets/html/_documentation.html 40 /assets/html/_documentation.html
41 tags 41 tags
42 -/trdata.h* 42 +trdata.h
@@ -51,9 +51,12 @@ TR_CLASS(TR_Queue) { @@ -51,9 +51,12 @@ TR_CLASS(TR_Queue) {
51 TR_INSTANCE_INIT(TR_Queue); 51 TR_INSTANCE_INIT(TR_Queue);
52 TR_CLASSVARS_DECL(TR_Queue) {}; 52 TR_CLASSVARS_DECL(TR_Queue) {};
53 53
54 -void TR_queuePut(TR_Queue, void *);  
55 -void TR_queuePutFirst(TR_Queue, void *);  
56 -void * TR_queueGet(TR_Queue); 54 +void TR_queuePut(TR_Queue, void *);
  55 +void TR_queuePutFirst(TR_Queue, void *);
  56 +void * TR_queueGet(TR_Queue);
  57 +TR_Queue TR_queueFind(TR_Queue, void *);
  58 +TR_Queue TR_queueFindParent(TR_Queue, void *);
  59 +void TR_queueDelete(TR_Queue, void *);
57 60
58 #define TR_queueEmpty(this) (0 >= (this)->nmsg) 61 #define TR_queueEmpty(this) (0 >= (this)->nmsg)
59 62
@@ -5,5 +5,12 @@ AM_CFLAGS += -I../../include/ @@ -5,5 +5,12 @@ AM_CFLAGS += -I../../include/
5 5
6 noinst_LTLIBRARIES = libqueue.la 6 noinst_LTLIBRARIES = libqueue.la
7 7
8 -libqueue_la_SOURCES = queue.c get.c put.c put_first.c 8 +libqueue_la_SOURCES = queue.c \
  9 + get.c \
  10 + put.c \
  11 + put_first.c \
  12 + find.c \
  13 + find_parent.c \
  14 + delete.c
  15 +
9 libqueue_la_CFLAGS = $(AM_CFLAGS) 16 libqueue_la_CFLAGS = $(AM_CFLAGS)
  1 +/**
  2 + * \file
  3 + *
  4 + * \author Georg Hopp
  5 + *
  6 + * \copyright
  7 + * Copyright © 2014 Georg Hopp
  8 + *
  9 + * This program is free software: you can redistribute it and/or modify
  10 + * it under the terms of the GNU General Public License as published by
  11 + * the Free Software Foundation, either version 3 of the License, or
  12 + * (at your option) any later version.
  13 + *
  14 + * This program is distributed in the hope that it will be useful,
  15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17 + * GNU General Public License for more details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + */
  22 +
  23 +#include "trbase.h"
  24 +#include "tr/queue.h"
  25 +
  26 +void
  27 +TR_queueDelete(TR_Queue this, void * msg)
  28 +{
  29 + TR_Queue node, parent = TR_queueFindParent(this, msg);
  30 +
  31 + if (! parent) return;
  32 +
  33 + node = parent->next;
  34 + parent->next = node->next;
  35 + if (node == this->last) {
  36 + this->last = parent;
  37 + }
  38 + TR_delete(node);
  39 + this->nmsg--;
  40 +}
  41 +
  42 +// vim: set ts=4 sw=4:
  1 +/**
  2 + * \file
  3 + *
  4 + * \author Georg Hopp
  5 + *
  6 + * \copyright
  7 + * Copyright © 2014 Georg Hopp
  8 + *
  9 + * This program is free software: you can redistribute it and/or modify
  10 + * it under the terms of the GNU General Public License as published by
  11 + * the Free Software Foundation, either version 3 of the License, or
  12 + * (at your option) any later version.
  13 + *
  14 + * This program is distributed in the hope that it will be useful,
  15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17 + * GNU General Public License for more details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + */
  22 +
  23 +#include "trbase.h"
  24 +#include "tr/queue.h"
  25 +
  26 +TR_Queue
  27 +TR_queueFind(TR_Queue this, void * msg)
  28 +{
  29 + TR_Queue node;
  30 +
  31 + for (node = this->first; node && node->msg != msg; node = node->next);
  32 +
  33 + return node;
  34 +}
  35 +
  36 +// vim: set ts=4 sw=4:
  1 +/**
  2 + * \file
  3 + *
  4 + * \author Georg Hopp
  5 + *
  6 + * \copyright
  7 + * Copyright © 2014 Georg Hopp
  8 + *
  9 + * This program is free software: you can redistribute it and/or modify
  10 + * it under the terms of the GNU General Public License as published by
  11 + * the Free Software Foundation, either version 3 of the License, or
  12 + * (at your option) any later version.
  13 + *
  14 + * This program is distributed in the hope that it will be useful,
  15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17 + * GNU General Public License for more details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21 + */
  22 +
  23 +#include "trbase.h"
  24 +#include "tr/queue.h"
  25 +
  26 +TR_Queue
  27 +TR_queueFindParent(TR_Queue this, void * msg)
  28 +{
  29 + TR_Queue node;
  30 +
  31 + for (node = this; node->next && node->next->msg != msg; node = node->next);
  32 +
  33 + return node->next ? node : NULL;
  34 +}
  35 +
  36 +// vim: set ts=4 sw=4:
1 -/* trdata.h. Generated from trdata.h.in by configure. */  
2 -/* trdata.h.in. Generated from configure.ac by autoheader. */  
3 -  
4 -/* Define to 1 if you have the <dlfcn.h> header file. */  
5 -#define HAVE_DLFCN_H 1  
6 -  
7 -/* Define to 1 if you have the <inttypes.h> header file. */  
8 -#define HAVE_INTTYPES_H 1  
9 -  
10 -/* Define to 1 if you have the <memory.h> header file. */  
11 -#define HAVE_MEMORY_H 1  
12 -  
13 -/* Define to 1 if you have the `memset' function. */  
14 -#define HAVE_MEMSET 1  
15 -  
16 -/* Define to 1 if you have the <stdarg.h> header file. */  
17 -#define HAVE_STDARG_H 1  
18 -  
19 -/* Define to 1 if stdbool.h conforms to C99. */  
20 -#define HAVE_STDBOOL_H 1  
21 -  
22 -/* Define to 1 if you have the <stdint.h> header file. */  
23 -#define HAVE_STDINT_H 1  
24 -  
25 -/* Define to 1 if you have the <stdio.h> header file. */  
26 -#define HAVE_STDIO_H 1  
27 -  
28 -/* Define to 1 if you have the <stdlib.h> header file. */  
29 -#define HAVE_STDLIB_H 1  
30 -  
31 -/* Define to 1 if you have the <strings.h> header file. */  
32 -#define HAVE_STRINGS_H 1  
33 -  
34 -/* Define to 1 if you have the <string.h> header file. */  
35 -#define HAVE_STRING_H 1  
36 -  
37 -/* Define to 1 if you have the <syslog.h> header file. */  
38 -#define HAVE_SYSLOG_H 1  
39 -  
40 -/* Define to 1 if you have the <sys/stat.h> header file. */  
41 -#define HAVE_SYS_STAT_H 1  
42 -  
43 -/* Define to 1 if you have the <sys/types.h> header file. */  
44 -#define HAVE_SYS_TYPES_H 1  
45 -  
46 -/* Define to 1 if you have the <unistd.h> header file. */  
47 -#define HAVE_UNISTD_H 1  
48 -  
49 -/* Define to 1 if the system has the type `_Bool'. */  
50 -#define HAVE__BOOL 1  
51 -  
52 -/* Define to the sub-directory in which libtool stores uninstalled libraries.  
53 - */  
54 -#define LT_OBJDIR ".libs/"  
55 -  
56 -/* Name of package */  
57 -#define PACKAGE "libtrhash"  
58 -  
59 -/* Define to the address where bug reports for this package should be sent. */  
60 -#define PACKAGE_BUGREPORT "Georg Hopp <georg@steffers.org>"  
61 -  
62 -/* Define to the full name of this package. */  
63 -#define PACKAGE_NAME "libtrhash"  
64 -  
65 -/* Define to the full name and version of this package. */  
66 -#define PACKAGE_STRING "libtrhash 0.0.0"  
67 -  
68 -/* Define to the one symbol short name of this package. */  
69 -#define PACKAGE_TARNAME "libtrhash"  
70 -  
71 -/* Define to the home page for this package. */  
72 -#define PACKAGE_URL ""  
73 -  
74 -/* Define to the version of this package. */  
75 -#define PACKAGE_VERSION "0.0.0"  
76 -  
77 -/* Define to 1 if you have the ANSI C header files. */  
78 -#define STDC_HEADERS 1  
79 -  
80 -/* Version number of package */  
81 -#define VERSION "0.0.0"  
82 -  
83 -/* Define to `__inline__' or `__inline' if that's what the C compiler  
84 - calls it, or to nothing if 'inline' is not supported under any name. */  
85 -#ifndef __cplusplus  
86 -/* #undef inline */  
87 -#endif  
88 -  
89 -/* Define to `int' if <sys/types.h> does not define. */  
90 -/* #undef pid_t */  
91 -  
92 -/* Define to `unsigned int' if <sys/types.h> does not define. */  
93 -/* #undef size_t */  
Please register or login to post a comment