Fix memory allocation problems
This commit is contained in:
parent
931794ddcb
commit
fb2416e51a
@ -102,9 +102,19 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
argc -= 5;
|
argc -= 5;
|
||||||
|
|
||||||
unsigned long deltas[input_size];
|
|
||||||
unsigned int num_tasks = 5;
|
unsigned int num_tasks = 5;
|
||||||
u_int32_t inputs[input_size];
|
int full_input_room = (int) pow(input_size, num_tasks);
|
||||||
|
printf("Full input room: %d\n", full_input_room);
|
||||||
|
unsigned long *deltas = malloc(full_input_room * sizeof(unsigned long));
|
||||||
|
if (deltas == NULL) {
|
||||||
|
fprintf(stderr, "Memory allocation failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
u_int32_t *inputs = malloc(full_input_room * sizeof(u_int32_t));
|
||||||
|
if (inputs == NULL) {
|
||||||
|
fprintf(stderr, "Memory allocation failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
//========= Instrumentation end
|
//========= Instrumentation end
|
||||||
qemu_init(argc, argv);
|
qemu_init(argc, argv);
|
||||||
//========= Instrumentation start
|
//========= Instrumentation start
|
||||||
@ -127,8 +137,9 @@ int main(int argc, char **argv)
|
|||||||
int task_inputs[num_tasks];
|
int task_inputs[num_tasks];
|
||||||
|
|
||||||
// input of all tasks combined
|
// input of all tasks combined
|
||||||
for (long i = 0; i < pow(input_size, num_tasks); i++)
|
for (long i = 0; i < full_input_room; i++)
|
||||||
{
|
{
|
||||||
|
printf("Input: %lu\n", i);
|
||||||
for (int j = 0; j < num_tasks; j++)
|
for (int j = 0; j < num_tasks; j++)
|
||||||
{
|
{
|
||||||
// from the "global input" i, extract the input bits for the task j
|
// from the "global input" i, extract the input bits for the task j
|
||||||
@ -195,12 +206,14 @@ int main(int argc, char **argv)
|
|||||||
// qemu_chr_fe_write(serial_chr, data, length);
|
// qemu_chr_fe_write(serial_chr, data, length);
|
||||||
FILE *fptr = fopen(output_path, "w");
|
FILE *fptr = fopen(output_path, "w");
|
||||||
|
|
||||||
for (int i = 0; i < input_size; i++)
|
for (int i = 0; i < full_input_room; i++)
|
||||||
{
|
{
|
||||||
fprintf(fptr, "%d,%lu\n", inputs[i], deltas[i]);
|
fprintf(fptr, "%d,%lu\n", inputs[i], deltas[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
|
free(deltas);
|
||||||
|
free(inputs);
|
||||||
// // Write some text to the file
|
// // Write some text to the file
|
||||||
// fprintf(fptr, "%lu",delta);
|
// fprintf(fptr, "%lu",delta);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user