version 1.241, 2006/03/20 18:48:34 |
version 1.242, 2006/03/25 00:05:41 |
|
|
/* Do initial allocation if this is the first call. */ |
/* Do initial allocation if this is the first call. */ |
if (channels_alloc == 0) { |
if (channels_alloc == 0) { |
channels_alloc = 10; |
channels_alloc = 10; |
channels = xmalloc(channels_alloc * sizeof(Channel *)); |
channels = xcalloc(channels_alloc, sizeof(Channel *)); |
for (i = 0; i < channels_alloc; i++) |
for (i = 0; i < channels_alloc; i++) |
channels[i] = NULL; |
channels[i] = NULL; |
} |
} |
|
|
channels[i] = NULL; |
channels[i] = NULL; |
} |
} |
/* Initialize and return new channel. */ |
/* Initialize and return new channel. */ |
c = channels[found] = xmalloc(sizeof(Channel)); |
c = channels[found] = xcalloc(1, sizeof(Channel)); |
memset(c, 0, sizeof(Channel)); |
|
buffer_init(&c->input); |
buffer_init(&c->input); |
buffer_init(&c->output); |
buffer_init(&c->output); |
buffer_init(&c->extended); |
buffer_init(&c->extended); |
|
|
} |
} |
|
|
/* Allocate a channel for each socket. */ |
/* Allocate a channel for each socket. */ |
*chanids = xmalloc(sizeof(**chanids) * (num_socks + 1)); |
*chanids = xcalloc(num_socks + 1, sizeof(**chanids)); |
for (n = 0; n < num_socks; n++) { |
for (n = 0; n < num_socks; n++) { |
sock = socks[n]; |
sock = socks[n]; |
nc = channel_new("x11 listener", |
nc = channel_new("x11 listener", |