diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-11-26 00:16:57 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2008-11-26 00:16:57 +0100 |
commit | 22353928caf9c821e70d15c2dd827c8725f6ac40 (patch) | |
tree | aa2c1475224a178cf9213805ae7b6c241512f02d | |
parent | 1bc6f65123550e52c7d37645709931b20ceff2b3 (diff) | |
download | conntrack-tools-22353928caf9c821e70d15c2dd827c8725f6ac40.tar.gz conntrack-tools-22353928caf9c821e70d15c2dd827c8725f6ac40.zip |
fds: remove unused array of file descriptors
This patch removes an unused array of file descriptors inside the
fds structure.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | include/fds.h | 3 | ||||
-rw-r--r-- | src/fds.c | 30 |
2 files changed, 1 insertions, 32 deletions
diff --git a/include/fds.h b/include/fds.h index cc213fe..019d3f9 100644 --- a/include/fds.h +++ b/include/fds.h @@ -3,9 +3,6 @@ struct fds { int maxfd; - int fd_array_len; - int fd_array_cur; - int *fd_array; fd_set readfds; }; @@ -19,35 +19,19 @@ #include <string.h> #include "fds.h" -/* we don't handle that many descriptors so eight is just fine */ -#define FDS_ARRAY_LEN 8 -#define FDS_ARRAY_SIZE (sizeof(int) * FDS_ARRAY_LEN) - struct fds *create_fds(void) { struct fds *fds; - fds = (struct fds *) malloc(sizeof(struct fds)); + fds = (struct fds *) calloc(sizeof(struct fds), 1); if (fds == NULL) return NULL; - memset(fds, 0, sizeof(struct fds)); - - fds->fd_array = (int *) malloc(FDS_ARRAY_SIZE); - if (fds->fd_array == NULL) { - free(fds); - return NULL; - } - - memset(fds->fd_array, 0, FDS_ARRAY_SIZE); - fds->fd_array_len = FDS_ARRAY_LEN; - return fds; } void destroy_fds(struct fds *fds) { - free(fds->fd_array); free(fds); } @@ -58,17 +42,5 @@ int register_fd(int fd, struct fds *fds) if (fd > fds->maxfd) fds->maxfd = fd; - if (fds->fd_array_cur >= fds->fd_array_len) { - fds->fd_array_len += FDS_ARRAY_LEN; - fds->fd_array = realloc(fds->fd_array, - fds->fd_array_len * sizeof(int)); - if (fds->fd_array == NULL) { - fds->fd_array_len -= FDS_ARRAY_LEN; - return -1; - } - } - - fds->fd_array[fds->fd_array_cur++] = fd; - return 0; } |