From: sopwith Date: Tue, 3 Apr 2001 21:13:45 +0000 (+0000) Subject: If someone calls newtFormWatchFd multiple times with the same fd, overwrite the exist... X-Git-Tag: r0-50-24~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b41399a386646dcac8ba40af914d8d70c37b326b;p=thirdparty%2Fnewt.git If someone calls newtFormWatchFd multiple times with the same fd, overwrite the existing fdInfo record instead of appending a new one. --- diff --git a/form.c b/form.c index 952f879..2d95d2a 100644 --- a/form.c +++ b/form.c @@ -1115,10 +1115,17 @@ void newtFormSetBackground(newtComponent co, int color) { void newtFormWatchFd(newtComponent co, int fd, int fdFlags) { struct form * form = co->data; + int i; + + for (i = 0; i < form->numFds; i++) + if (form->fds[i].fd == fd) + break; + + if(i >= form->numFds) + form->fds = realloc(form->fds, (++form->numFds) * sizeof(*form->fds)); - form->fds = realloc(form->fds, (form->numFds + 1) * sizeof(*form->fds)); - form->fds[form->numFds].fd = fd; - form->fds[form->numFds++].flags = fdFlags; + form->fds[i].fd = fd; + form->fds[i].flags = fdFlags; if (form->maxFd < fd) form->maxFd = fd; }