summaryrefslogtreecommitdiffstats
path: root/src/bufferq.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-10-09 18:15:23 +0200
committerLennart Poettering <lennart@poettering.net>2008-10-09 18:15:23 +0200
commit181e9c6d5d11cb1e5d36a2777eeb233ad8ed00e5 (patch)
tree7c280968ce3fded5b325b1480d7f2440ddf93207 /src/bufferq.c
parent30a4b516c8d591c11f05df38531f46452d930d2b (diff)
big pile of updates to match more what happened with libcanberra
Diffstat (limited to 'src/bufferq.c')
-rw-r--r--src/bufferq.c46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/bufferq.c b/src/bufferq.c
index 46f9bbc..f2effd1 100644
--- a/src/bufferq.c
+++ b/src/bufferq.c
@@ -1,3 +1,23 @@
+/***
+ This file is part of libsydney.
+
+ Copyright 2007-2008 Lennart Poettering
+
+ libsydney is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 2.1 of the
+ License, or (at your option) any later version.
+
+ libsydney 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with libsydney. If not, see
+ <http://www.gnu.org/licenses/>.
+***/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -122,12 +142,12 @@ int sa_bufferq_push(sa_bufferq_t *q, unsigned channel, const void *data, size_t
if (q->read_index > idx && type != SA_BUFFERQ_ITEM_DYNAMIC) {
int64_t l = q->read_index - idx;
- if (l > nbytes)
- l = nbytes;
+ if (l > (int64_t) nbytes)
+ l = (int64_t) nbytes;
idx += l;
data = (const uint8_t*) data + l;
- nbytes -= l;
+ nbytes -= (size_t) l;
}
@@ -136,12 +156,12 @@ int sa_bufferq_push(sa_bufferq_t *q, unsigned channel, const void *data, size_t
return SA_ERROR_OOM;
/* Find the position where we need to insert the new entry */
- for (i = q->items[channel]; i && idx >= i->idx + i->size; i = i->bufferq_next)
+ for (i = q->items[channel]; i && idx >= i->idx + (int64_t) i->size; i = i->bufferq_next)
;
/* Shorten the current entry if necessary */
if (i && idx > i->idx) {
- i->size = idx - i->idx;
+ i->size = (size_t) (idx - i->idx);
i = i->bufferq_next;
}
@@ -158,13 +178,13 @@ int sa_bufferq_push(sa_bufferq_t *q, unsigned channel, const void *data, size_t
}
/* Now kick all the entries that overlap entirely with our new entry */
- for (i = j->bufferq_next; i && i->idx + i->size < j->idx + j->size ; i = n) {
+ for (i = j->bufferq_next; i && i->idx + (int64_t) i->size < j->idx + (int64_t) j->size ; i = n) {
n = i->bufferq_next;
SA_LLIST_REMOVE(sa_bufferq_item_t, bufferq, q->items[channel], i);
bufferq_item_free(i);
}
- q->write_index = idx + nbytes;
+ q->write_index = idx + (int64_t) nbytes;
if (q->write_index > q->end_index)
q->end_index = q->write_index;
@@ -190,22 +210,22 @@ void sa_bufferq_get(sa_bufferq_t *q, void *i[], size_t *bytes) {
l = q->items[u]->idx - q->read_index;
if (first) {
- *bytes = l;
+ *bytes = (size_t) l;
first = FALSE;
} else
- *bytes = l < *bytes ? l : *bytes;
+ *bytes = l < (int64_t) *bytes ? (size_t) l : *bytes;
} else {
int64_t l;
i[u] = (uint8_t*) q->items[u]->data + q->read_index - q->items[u]->idx;
- l = q->items[u]->size - (q->read_index - q->items[u]->idx);
+ l = (int64_t) q->items[u]->size - (q->read_index - q->items[u]->idx);
if (first) {
- *bytes = l;
+ *bytes = (size_t) l;
first = FALSE;
} else
- *bytes = l < *bytes ? l : *bytes;
+ *bytes = l < (int64_t) *bytes ? (size_t) l : *bytes;
}
} else
@@ -225,7 +245,7 @@ void sa_bufferq_drop(sa_bufferq_t *q, int64_t bytes) {
i = q->items[u];
- while (i && q->read_index >= i->idx + i->size) {
+ while (i && q->read_index >= i->idx + (int64_t) i->size) {
sa_bufferq_item_t *n = i->bufferq_next;
SA_LLIST_REMOVE(sa_bufferq_item_t, bufferq, q->items[u], i);