Factor out QUEUE_EMPTY macro

This commit is contained in:
David Tolnay 2022-07-22 17:00:18 -07:00
parent 268489873b
commit c4448a4c90
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 6 additions and 4 deletions

View file

@ -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);

View file

@ -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 {

View file

@ -485,7 +485,9 @@ macro_rules! QUEUE_DEL {
}
macro_rules! QUEUE_EMPTY {
() => {}; // TODO
($queue:expr) => {
$queue.head == $queue.tail
};
}
macro_rules! ENQUEUE {