/** * Gets the last element of the array or the element at the highest index * and sets the out parameter to its value. * * @param[in] ar the array whose last element is being returned * @param[out] out pointer to where the element is stored * * @return CC_OK if the element was found, or CC_ERR_VALUE_NOT_FOUND if the * Array is empty. */ enum cc_stat array_get_last(Array *ar, void **out) { if (ar->size == 0) return CC_ERR_VALUE_NOT_FOUND; return array_get_at(ar, ar->size - 1, out); }
void process_init(proc_t* process) { thread_t* main_thread = array_get_at(process->threads, 0); main_thread->local_info = proc_alloc_direct(process, sizeof(tli_t)); if (main_thread->local_info == NULL) { error(ERROR_MINIMAL_MEMORY_FAILURE, 0, 0, &create_init_process_structure); } main_thread->local_info->self = main_thread->local_info; main_thread->local_info->t = main_thread->tId; for (int i=0; i<MESSAGE_BUFFER_CNT; i++) { _message_t* m = &process->output_buffer[i]; m->owner = process; m->used = false; m->message = proc_alloc_direct(process, 0x200000); if (m->message == NULL) { error(ERROR_MINIMAL_MEMORY_FAILURE, 0, 0, &create_init_process_structure); } } }