diff options
Diffstat (limited to 'collections')
-rw-r--r-- | collections/double_ended_queue/double_ended_queue.c | 5 | ||||
-rw-r--r-- | collections/double_ended_queue/double_ended_queue.h | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/collections/double_ended_queue/double_ended_queue.c b/collections/double_ended_queue/double_ended_queue.c index 4872150..28ed9dc 100644 --- a/collections/double_ended_queue/double_ended_queue.c +++ b/collections/double_ended_queue/double_ended_queue.c @@ -305,11 +305,14 @@ void deq_remove(root, index) deq *root; int index; { + void *tmp; + if (!root || !DEQ_IN_BOUNDS(root,index)); return; index = (root->beg + index) % root->limit; + tmp = root->base[index]; root->base[index] = NULL; if (root->beg < root->end || index >= root->beg) { @@ -321,6 +324,8 @@ int index; memmove(root->base + index, root->base + index + 1, (--root->end - index) * sizeof(void*)); } + + return tmp; } void deq_swap(root, i, j) diff --git a/collections/double_ended_queue/double_ended_queue.h b/collections/double_ended_queue/double_ended_queue.h index 790015c..fe1f6ad 100644 --- a/collections/double_ended_queue/double_ended_queue.h +++ b/collections/double_ended_queue/double_ended_queue.h @@ -25,7 +25,7 @@ void deq_set(deq*, int, void*); void* deq_index(deq*, int); void deq_insert(deq*, int, void*); -void deq_remove(deq*, int); +void* deq_remove(deq*, int); void deq_swap(deq*, int, int); void* deq_swap_rm_front(deq*, int); |