Stop too many bytes for activequeues.

We were saying calloc(N,N*sizeof(struct event_list*)) when we should have
been saying calloc(N,sizeof(struct event_list*)).  This wasted N*(N-1) words
of memory, where N was the number of priorities.  This wouldn't be a big deal
for any sane number of priorities, but it's a bug nonetheless.

svn:r1526
This commit is contained in:
Nick Mathewson 2009-11-09 19:55:40 +00:00
parent e32d055b5e
commit b4183c732e
2 changed files with 3 additions and 2 deletions

View File

@ -5,6 +5,7 @@ Changes in 1.4.13-stable:
o Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec
o Rename our replacement compat/sys/_time.h header to avoid build a conflict on HPUX; reported by Kathryn Hogg.
o Build kqueue.c correctly on GNU/kFreeBSD platforms. Patch pulled upstream from Debian.
o Fix a problem with excessive memory allocation when using multiple event priorities.
Changes in 1.4.12-stable:

View File

@ -326,8 +326,8 @@ event_base_priority_init(struct event_base *base, int npriorities)
/* Allocate our priority queues */
base->nactivequeues = npriorities;
base->activequeues = (struct event_list **)calloc(base->nactivequeues,
npriorities * sizeof(struct event_list *));
base->activequeues = (struct event_list **)
calloc(base->nactivequeues, sizeof(struct event_list *));
if (base->activequeues == NULL)
event_err(1, "%s: calloc", __func__);