Lines Matching refs:chunk

30     mem->chunk = lexbor_mem_chunk_make(mem, mem->chunk_min_size);  in lexbor_mem_init()
31 if (mem->chunk == NULL) { in lexbor_mem_init()
36 mem->chunk_first = mem->chunk; in lexbor_mem_init()
44 lexbor_mem_chunk_t *prev, *chunk; in lexbor_mem_clean() local
50 chunk = mem->chunk; in lexbor_mem_clean()
52 while (chunk->prev) { in lexbor_mem_clean()
53 prev = chunk->prev; in lexbor_mem_clean()
55 chunk->data = lexbor_free(chunk->data); in lexbor_mem_clean()
56 lexbor_free(chunk); in lexbor_mem_clean()
58 chunk = prev; in lexbor_mem_clean()
61 chunk->next = NULL; in lexbor_mem_clean()
62 chunk->length = 0; in lexbor_mem_clean()
64 mem->chunk = mem->chunk_first; in lexbor_mem_clean()
71 lexbor_mem_chunk_t *chunk, *prev; in lexbor_mem_destroy() local
78 if (mem->chunk) { in lexbor_mem_destroy()
79 chunk = mem->chunk; in lexbor_mem_destroy()
81 while (chunk) { in lexbor_mem_destroy()
82 prev = chunk->prev; in lexbor_mem_destroy()
83 lexbor_mem_chunk_destroy(mem, chunk, true); in lexbor_mem_destroy()
84 chunk = prev; in lexbor_mem_destroy()
87 mem->chunk = NULL; in lexbor_mem_destroy()
99 lexbor_mem_chunk_t *chunk, size_t length) in lexbor_mem_chunk_init() argument
105 chunk->size = length; in lexbor_mem_chunk_init()
108 chunk->size = length + mem->chunk_min_size; in lexbor_mem_chunk_init()
112 chunk->size = mem->chunk_min_size; in lexbor_mem_chunk_init()
115 chunk->length = 0; in lexbor_mem_chunk_init()
116 chunk->data = lexbor_malloc(chunk->size * sizeof(uint8_t)); in lexbor_mem_chunk_init()
118 return chunk->data; in lexbor_mem_chunk_init()
124 lexbor_mem_chunk_t *chunk = lexbor_calloc(1, sizeof(lexbor_mem_chunk_t)); in lexbor_mem_chunk_make() local
126 if (chunk == NULL) { in lexbor_mem_chunk_make()
130 if (lexbor_mem_chunk_init(mem, chunk, length) == NULL) { in lexbor_mem_chunk_make()
131 return lexbor_free(chunk); in lexbor_mem_chunk_make()
134 return chunk; in lexbor_mem_chunk_make()
139 lexbor_mem_chunk_t *chunk, bool self_destroy) in lexbor_mem_chunk_destroy() argument
141 if (chunk == NULL || mem == NULL) { in lexbor_mem_chunk_destroy()
145 if (chunk->data) { in lexbor_mem_chunk_destroy()
146 chunk->data = lexbor_free(chunk->data); in lexbor_mem_chunk_destroy()
150 return lexbor_free(chunk); in lexbor_mem_chunk_destroy()
153 return chunk; in lexbor_mem_chunk_destroy()
165 if ((mem->chunk->length + length) > mem->chunk->size) { in lexbor_mem_alloc()
170 mem->chunk->next = lexbor_mem_chunk_make(mem, length); in lexbor_mem_alloc()
171 if (mem->chunk->next == NULL) { in lexbor_mem_alloc()
175 mem->chunk->next->prev = mem->chunk; in lexbor_mem_alloc()
176 mem->chunk = mem->chunk->next; in lexbor_mem_alloc()
181 mem->chunk->length += length; in lexbor_mem_alloc()
183 return &mem->chunk->data[(mem->chunk->length - length)]; in lexbor_mem_alloc()