struct instruction *instruction_create_from_words(uint32_t *words, unsigned int count) { struct instruction *inst; unsigned int i; inst = calloc(1, sizeof(*inst)); if (!inst) return NULL; inst->length = count * 32; inst->bits = malloc(sizeof(*words) * count); if (!inst->bits) { instruction_free(inst); return NULL; } inst->taken = calloc(1, sizeof(*words) * count); if (!inst->taken) { instruction_free(inst); return NULL; } for (i = 0; i < count; i++) inst->bits[i] = words[count - i - 1]; return inst; }
void instruction_list_free (instruction_list * list) { instruction_list * current, * tmp; for (current = list; current != NULL; current = tmp) { instruction * i = current->element; tmp = current->next; instruction_free (i); free (current); } }