Fix all Valgrind errors: uninitialized values and memory leak
This commit resolves all Valgrind errors reported in the test run: 1. Fixed uninitialized 'removed' array in tcp_translate_events (tcp.c:179) - Added memset to initialize the array to zero before use 2. Fixed uninitialized RequestQueue in client initialization (client.c) - Added initialization of metadata_server.reqs and chunk_servers[].reqs - Added forward declaration of request_queue_init function 3. Fixed uninitialized descriptor generation field (system.c:324) - Initialize generation to 0 when creating process descriptors - Prevents uninitialized value errors in handle_to_desc 4. Fixed 34-byte memory leak in tcp_context_free (tcp.c:91-103) - Added cleanup of connection byte queues when freeing TCP context - Frees both input and output ByteQueues for all connections All Valgrind errors have been resolved: - ERROR SUMMARY: 0 errors from 0 contexts - All heap blocks freed - no leaks possible
This commit is contained in:
+3
-1
@@ -319,8 +319,10 @@ int spawn_simulated_process(char *args)
|
||||
process->num_desc = 0;
|
||||
process->num_allocs = 0;
|
||||
|
||||
for (int i = 0; i < MAX_DESCRIPTORS; i++)
|
||||
for (int i = 0; i < MAX_DESCRIPTORS; i++) {
|
||||
process->desc[i].type = DESC_EMPTY;
|
||||
process->desc[i].generation = 0;
|
||||
}
|
||||
|
||||
void *contexts[MAX_CONNS+1];
|
||||
struct pollfd polled[MAX_CONNS+1];
|
||||
|
||||
Reference in New Issue
Block a user