2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifndef __SWFDEC_RING_BUFFER_H__
21 #define __SWFDEC_RING_BUFFER_H__
28 typedef struct _SwfdecRingBuffer SwfdecRingBuffer
;
30 struct _SwfdecRingBuffer
32 unsigned char * data
; /* our data */
33 gsize element_size
; /* size of one element */
34 guint size
; /* number of elements in the buffer */
36 guint head
; /* index of first element */
37 guint tail
; /* index after last element */
38 guint n_elements
; /* number of elements in ringbuffer */
41 SwfdecRingBuffer
* swfdec_ring_buffer_new (guint element_size
,
43 #define swfdec_ring_buffer_new_for_type(element_type,size) \
44 swfdec_ring_buffer_new (sizeof (element_type), (size))
45 void swfdec_ring_buffer_free (SwfdecRingBuffer
* buffer
);
47 guint
swfdec_ring_buffer_get_size (SwfdecRingBuffer
* buffer
);
48 void swfdec_ring_buffer_set_size (SwfdecRingBuffer
* buffer
,
50 guint
swfdec_ring_buffer_get_n_elements (SwfdecRingBuffer
* buffer
);
52 gpointer
swfdec_ring_buffer_push (SwfdecRingBuffer
* buffer
);
53 gpointer
swfdec_ring_buffer_pop (SwfdecRingBuffer
* buffer
);
54 gpointer
swfdec_ring_buffer_peek_nth (SwfdecRingBuffer
* buffer
,