As API is passing structures by value, do not leave
the function which created buffer and keeps valid pointer
look like it would be some memory leak and move
free of buffer from inner function - makes more obvious,
how is the memory management handled.
if (!write_buffer(h.socket_fd, rq.buffer, strlen(rq.buffer)))
reply.error = errno;
- dm_free(rq.buffer);
-
if (read_buffer(h.socket_fd, &reply.buffer)) {
reply.cft = dm_config_from_string(reply.buffer);
} else
return err;
repl = daemon_send(h, rq);
+ dm_free(rq.buffer);
+
return repl;
}