Skip to content
Snippets Groups Projects
Commit 044f938b authored by Ruben Otto's avatar Ruben Otto :crab:
Browse files

fix: fix daemon memory leak

parent f2b03689
No related branches found
No related tags found
No related merge requests found
...@@ -86,24 +86,19 @@ int main() { ...@@ -86,24 +86,19 @@ int main() {
sigaction(SIGINT, &signal_action, NULL); sigaction(SIGINT, &signal_action, NULL);
while (1) { while (1) {
measurement_t *measurement = malloc(sizeof(measurement_t)); measurement_t measurement;
if (measurement == NULL) { if (recv_userspace_message(&userspace_receive_handle, &measurement) != 0) {
perror("Failed to allocate memory for measurement message");
return EXIT_FAILURE;
}
if (recv_userspace_message(&userspace_receive_handle, measurement) != 0) {
continue; continue;
} }
printf("Received data from %d: ", measurement->id); printf("Received data from %d: ", measurement.id);
print_measurement_data(measurement); print_measurement_data(&measurement);
data_t data = { data_t data = {
.sender_id = SENDER_ID, .sender_id = SENDER_ID,
.count = 1, .count = 1,
.measurements = measurement, .measurements = &measurement,
}; };
if (send_kernel_message(&kernel_send_handle, &data) == -1) { if (send_kernel_message(&kernel_send_handle, &data) == -1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment