Browse Source

add put_first

1.0.0
Georg Hopp 11 years ago
parent
commit
35fa742df4
  1. 1
      include/tr/queue.h
  2. 2
      src/queue/Makefile.am
  3. 37
      src/queue/put_first.c

1
include/tr/queue.h

@ -52,6 +52,7 @@ 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);
#define TR_queueEmpty(this) (0 >= (this)->nmsg)

2
src/queue/Makefile.am

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

37
src/queue/put_first.c

@ -0,0 +1,37 @@
/**
* \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 = this->first;
this->first = TR_new(TR_Queue);
this->first->next = current_first;
this->first->msg = msg;
this->nmsg++;
}
// vim: set ts=4 sw=4:
Loading…
Cancel
Save