aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-03-20 20:23:12 +0100
committercbdev <cb@cbcdn.com>2019-03-20 20:23:12 +0100
commit63643cc99a8d621a82111fd6d4d69f80379d2933 (patch)
tree61ce94ea82f3eeb1dce7a6b333f9eff4f826a812
parent0928bc2c59a38c411a35c49d83fd468e5e0dc43c (diff)
downloadmidimonster-63643cc99a8d621a82111fd6d4d69f80379d2933.tar.gz
midimonster-63643cc99a8d621a82111fd6d4d69f80379d2933.tar.bz2
midimonster-63643cc99a8d621a82111fd6d4d69f80379d2933.zip
Fix signaled fd storage reallocation
-rw-r--r--midimonster.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/midimonster.c b/midimonster.c
index 798f06d..00d11f3 100644
--- a/midimonster.c
+++ b/midimonster.c
@@ -280,20 +280,19 @@ int main(int argc, char** argv){
signal(SIGINT, signal_handler);
- //allocate data buffers
- signaled_fds = calloc(fds, sizeof(managed_fd));
- if(!signaled_fds){
- fprintf(stderr, "Failed to allocate memory\n");
- goto bail;
- }
-
//process events
while(!shutdown_requested){
- //build fd set if necessary
+ //rebuild fd set if necessary
if(fd_set_dirty){
all_fds = fds_collect(&maxfd);
+ signaled_fds = realloc(signaled_fds, fds * sizeof(managed_fd));
+ if(!signaled_fds){
+ fprintf(stderr, "Failed to allocate memory\n");
+ goto bail;
+ }
fd_set_dirty = 0;
}
+
//wait for & translate events
read_fds = all_fds;
tv = backend_timeout();