| 139 | */ |
| 140 | |
| 141 | YAML_DECLARE(int) |
| 142 | yaml_queue_extend(void **start, void **head, void **tail, void **end) |
| 143 | { |
| 144 | /* Check if we need to resize the queue. */ |
| 145 | |
| 146 | if (*start == *head && *tail == *end) { |
| 147 | void *new_start = yaml_realloc(*start, |
| 148 | ((char *)*end - (char *)*start)*2); |
| 149 | |
| 150 | if (!new_start) return 0; |
| 151 | |
| 152 | *head = (char *)new_start + ((char *)*head - (char *)*start); |
| 153 | *tail = (char *)new_start + ((char *)*tail - (char *)*start); |
| 154 | *end = (char *)new_start + ((char *)*end - (char *)*start)*2; |
| 155 | *start = new_start; |
| 156 | } |
| 157 | |
| 158 | /* Check if we need to move the queue at the beginning of the buffer. */ |
| 159 | |
| 160 | if (*tail == *end) { |
| 161 | if (*head != *tail) { |
| 162 | memmove(*start, *head, (char *)*tail - (char *)*head); |
| 163 | } |
| 164 | *tail = (char *)*tail - (char *)*head + (char *)*start; |
| 165 | *head = *start; |
| 166 | } |
| 167 | |
| 168 | return 1; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | /* |
nothing calls this directly
no test coverage detected