queue: add requeue, fix unqueue_matching

Synchronized with emane.git's implementation of this code which
includes a unit test.

This commit also fixes two bugs in unqueue_matching and one inb
unqueue:

- unqueue_matching was returning the wrong pointer when
  there was no match

- both unqueue_matching and unqueue were not clearing the vacated
  queue entry after removing the item
This commit is contained in:
Michael Cook
2020-10-20 09:04:23 -04:00
parent d449a4de8a
commit 6dd80ffd2f
5 changed files with 375 additions and 53 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
opts=(
-Wall -Werror
-Wno-error=int-to-pointer-cast
-Wno-int-to-pointer-cast
-DUNITTEST
)
set -x
gcc "${opts[@]}" -fsanitize=address -o queue_test queue_test.c queue.c || exit
./queue_test || exit
gcc "${opts[@]}" -o queue_test queue_test.c queue.c || exit
valgrind ./queue_test || exit
: PASS