MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / yaml_queue_extend

Function yaml_queue_extend

external/libyaml/src/api.c:141–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139 */
140
141YAML_DECLARE(int)
142yaml_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/*

Callers

nothing calls this directly

Calls 1

yaml_reallocFunction · 0.85

Tested by

no test coverage detected