Browse Source

add more list like functions to the queue .. they are not used now and not testes, so they probably have bugs.

1.0.0
Georg Hopp 11 years ago
parent
commit
96d30bb5f3
  1. 2
      .gitignore
  2. 9
      include/tr/queue.h
  3. 9
      src/queue/Makefile.am
  4. 42
      src/queue/delete.c
  5. 36
      src/queue/find.c
  6. 36
      src/queue/find_parent.c
  7. 93
      trdata.h

2
.gitignore

@ -39,4 +39,4 @@ gmon.out
test-driver
/assets/html/_documentation.html
tags
/trdata.h*
trdata.h

9
include/tr/queue.h

@ -51,9 +51,12 @@ TR_CLASS(TR_Queue) {
TR_INSTANCE_INIT(TR_Queue);
TR_CLASSVARS_DECL(TR_Queue) {};
void TR_queuePut(TR_Queue, void *);
void TR_queuePutFirst(TR_Queue, void *);
void * TR_queueGet(TR_Queue);
void TR_queuePut(TR_Queue, void *);
void TR_queuePutFirst(TR_Queue, void *);
void * TR_queueGet(TR_Queue);
TR_Queue TR_queueFind(TR_Queue, void *);
TR_Queue TR_queueFindParent(TR_Queue, void *);
void TR_queueDelete(TR_Queue, void *);
#define TR_queueEmpty(this) (0 >= (this)->nmsg)

9
src/queue/Makefile.am

@ -5,5 +5,12 @@ AM_CFLAGS += -I../../include/
noinst_LTLIBRARIES = libqueue.la
libqueue_la_SOURCES = queue.c get.c put.c put_first.c
libqueue_la_SOURCES = queue.c \
get.c \
put.c \
put_first.c \
find.c \
find_parent.c \
delete.c
libqueue_la_CFLAGS = $(AM_CFLAGS)

42
src/queue/delete.c

@ -0,0 +1,42 @@
/**
* \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 = TR_queueFindParent(this, msg);
if (! parent) return;
node = parent->next;
parent->next = node->next;
if (node == this->last) {
this->last = parent;
}
TR_delete(node);
this->nmsg--;
}
// vim: set ts=4 sw=4:

36
src/queue/find.c

@ -0,0 +1,36 @@
/**
* \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:

36
src/queue/find_parent.c

@ -0,0 +1,36 @@
/**
* \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:

93
trdata.h

@ -1,93 +0,0 @@
/* trdata.h. Generated from trdata.h.in by configure. */
/* trdata.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the <stdarg.h> header file. */
#define HAVE_STDARG_H 1
/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <syslog.h> header file. */
#define HAVE_SYSLOG_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "libtrhash"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "Georg Hopp <georg@steffers.org>"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libtrhash"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libtrhash 0.0.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libtrhash"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.0.0"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "0.0.0"
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `int' if <sys/types.h> does not define. */
/* #undef pid_t */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
Loading…
Cancel
Save