src/queue.c: minor stuff. uint16_t -> unsigned int and a NULL check.
This commit is contained in:
parent
463d432104
commit
ce520fc35b
1 changed files with 4 additions and 2 deletions
|
|
@ -11,7 +11,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "xalloc.h"
|
#include "xalloc.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
|
|
@ -30,7 +29,7 @@ struct node {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ref {
|
struct ref {
|
||||||
uint16_t i;
|
unsigned int i;
|
||||||
struct node *n;
|
struct node *n;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -74,6 +73,9 @@ void queue_destroy(queue_t q) {
|
||||||
|
|
||||||
void queue_enqueue(queue_t q, void *obj) {
|
void queue_enqueue(queue_t q, void *obj) {
|
||||||
|
|
||||||
|
if (q == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (q->head.n == NULL) {
|
if (q->head.n == NULL) {
|
||||||
q->tail.n = q->head.n = xmalloc(sizeof(struct node));
|
q->tail.n = q->head.n = xmalloc(sizeof(struct node));
|
||||||
} else if (q->head.i + 1 >= BLOCK_SIZE) {
|
} else if (q->head.i + 1 >= BLOCK_SIZE) {
|
||||||
|
|
|
||||||
Reference in a new issue