Skip to content
Snippets Groups Projects
Commit a29cf52b authored by dawehr's avatar dawehr
Browse files

Made it so logging won't segfault/write to random memory if not initialized.

parent bbd1dcf1
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
// Current index of the log array // Current index of the log array
int arrayIndex = 0; int arrayIndex = 0;
// Size of the array // Size of the array
int arraySize = LOG_STARTING_SIZE; int arraySize = 0;
struct graph_tuple { // Tuple for struct graph_tuple { // Tuple for
int block_id; int block_id;
...@@ -38,7 +38,7 @@ struct graph_tuple log_params[MAX_LOG_NUM]; ...@@ -38,7 +38,7 @@ struct graph_tuple log_params[MAX_LOG_NUM];
size_t n_outputs; size_t n_outputs;
size_t n_params; size_t n_params;
float* logArray; float* logArray = NULL;
int row_size; int row_size;
static char units_output_str[512] = {}; static char units_output_str[512] = {};
...@@ -112,6 +112,8 @@ void initialize_logging(log_t* log_struct, parameter_t* ps) { ...@@ -112,6 +112,8 @@ void initialize_logging(log_t* log_struct, parameter_t* ps) {
logArray = malloc(needed_memory); logArray = malloc(needed_memory);
if (!logArray) { // malloc failed if (!logArray) { // malloc failed
arraySize = 0; arraySize = 0;
} else {
arraySize = LOG_STARTING_SIZE;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment