mirror of
https://github.com/simonask/libyaml-safer
synced 2024-11-23 03:43:03 +00:00
Factor out QUEUE_EMPTY macro
This commit is contained in:
parent
268489873b
commit
c4448a4c90
3 changed files with 6 additions and 4 deletions
|
@ -250,7 +250,7 @@ pub unsafe fn yaml_parser_delete(parser: *mut yaml_parser_t) {
|
|||
__assert!(!parser.is_null());
|
||||
BUFFER_DEL!((*parser).raw_buffer);
|
||||
BUFFER_DEL!((*parser).buffer);
|
||||
while !((*parser).tokens.head == (*parser).tokens.tail) {
|
||||
while !QUEUE_EMPTY!((*parser).tokens) {
|
||||
yaml_token_delete(addr_of_mut!(DEQUEUE!((*parser).tokens)));
|
||||
}
|
||||
QUEUE_DEL!((*parser).tokens);
|
||||
|
@ -394,7 +394,7 @@ pub unsafe fn yaml_emitter_delete(emitter: *mut yaml_emitter_t) {
|
|||
BUFFER_DEL!((*emitter).buffer);
|
||||
BUFFER_DEL!((*emitter).raw_buffer);
|
||||
STACK_DEL!((*emitter).states);
|
||||
while !((*emitter).events.head == (*emitter).events.tail) {
|
||||
while !QUEUE_EMPTY!((*emitter).events) {
|
||||
yaml_event_delete(addr_of_mut!(DEQUEUE!((*emitter).events)));
|
||||
}
|
||||
QUEUE_DEL!((*emitter).events);
|
||||
|
|
|
@ -149,7 +149,7 @@ pub unsafe fn yaml_emitter_emit(
|
|||
unsafe fn yaml_emitter_need_more_events(emitter: *mut yaml_emitter_t) -> libc::c_int {
|
||||
let mut level: libc::c_int = 0_i32;
|
||||
let mut event: *mut yaml_event_t;
|
||||
if (*emitter).events.head == (*emitter).events.tail {
|
||||
if QUEUE_EMPTY!((*emitter).events) {
|
||||
return 1_i32;
|
||||
}
|
||||
let accumulate = match (*(*emitter).events.head).type_ as libc::c_uint {
|
||||
|
|
|
@ -485,7 +485,9 @@ macro_rules! QUEUE_DEL {
|
|||
}
|
||||
|
||||
macro_rules! QUEUE_EMPTY {
|
||||
() => {}; // TODO
|
||||
($queue:expr) => {
|
||||
$queue.head == $queue.tail
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! ENQUEUE {
|
||||
|
|
Loading…
Reference in a new issue