• Home
  • Raw
  • Download

Lines Matching refs:tasks

121     struct loadtasks *tasks = __libc_malloc(sizeof(struct loadtasks));  in create_loadtasks()  local
122 if (tasks) { in create_loadtasks()
123 tasks->array = NULL; in create_loadtasks()
124 tasks->capacity = 0; in create_loadtasks()
125 tasks->length = 0; in create_loadtasks()
126 return tasks; in create_loadtasks()
131 bool append_loadtasks(struct loadtasks *tasks, struct loadtask *item) in append_loadtasks() argument
133 if (tasks->length + 1 > tasks->capacity) { in append_loadtasks()
135 new_cap = tasks->capacity + TASK_BASE_CAPACITY; in append_loadtasks()
137 if (tasks->array) { in append_loadtasks()
138 realloced = __libc_realloc(tasks->array, new_cap * sizeof(struct loadtask *)); in append_loadtasks()
143 tasks->array = realloced; in append_loadtasks()
144 tasks->capacity = new_cap; in append_loadtasks()
149 tasks->array[tasks->length] = item; in append_loadtasks()
150 tasks->length += 1; in append_loadtasks()
184 struct loadtask *get_loadtask(struct loadtasks *tasks, size_t index) in get_loadtask() argument
186 if (tasks && tasks->array && (index < tasks->length)) { in get_loadtask()
187 return tasks->array[index]; in get_loadtask()
193 void free_loadtasks(struct loadtasks *tasks) in free_loadtasks() argument
195 if (tasks) { in free_loadtasks()
196 if (tasks->length) { in free_loadtasks()
197 for (int i = 0; i < tasks->length; i++) { in free_loadtasks()
198 free_task(get_loadtask(tasks, i)); in free_loadtasks()
200 tasks->length = 0; in free_loadtasks()
202 if (tasks->array) { in free_loadtasks()
203 __libc_free(tasks->array); in free_loadtasks()
204 tasks->array = NULL; in free_loadtasks()
206 tasks->capacity = 0; in free_loadtasks()
207 __libc_free(tasks); in free_loadtasks()
211 void shuffle_loadtasks(struct loadtasks *tasks) in shuffle_loadtasks() argument
215 for (size_t i = 0; i < tasks->length; i++) { in shuffle_loadtasks()
219 index %= tasks->length; in shuffle_loadtasks()
220 task = tasks->array[i]; in shuffle_loadtasks()
221 tasks->array[i] = tasks->array[index]; in shuffle_loadtasks()
222 tasks->array[index] = task; in shuffle_loadtasks()