/[hurd]/hurd/libpipe/pq.c
ViewVC logotype

Diff of /hurd/libpipe/pq.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by tb, Sun Jul 11 05:30:36 1999 UTC revision 1.12 by marcus, Mon Apr 22 20:06:40 2002 UTC
# Line 127  pq_queue (struct pq *pq, unsigned type, Line 127  pq_queue (struct pq *pq, unsigned type,
127        packet->buf = 0;        packet->buf = 0;
128        packet->buf_len = 0;        packet->buf_len = 0;
129        packet->ports = 0;        packet->ports = 0;
130        packet->num_ports = packet->ports_alloced = 0;        packet->ports_alloced = 0;
       packet->buf_start = packet->buf_end = packet->buf;  
131        packet->buf_vm_alloced = 0;        packet->buf_vm_alloced = 0;
132      }      }
133    else    else
134      pq->free = packet->next;      pq->free = packet->next;
135    
136      packet->num_ports = 0;
137      packet->buf_start = packet->buf_end = packet->buf;
138    
139    packet->type = type;    packet->type = type;
140    packet->source = source;    packet->source = source;
141    packet->next = 0;    packet->next = 0;
# Line 295  packet_set_ports (struct packet *packet, Line 297  packet_set_ports (struct packet *packet,
297      packet_dealloc_ports (packet);      packet_dealloc_ports (packet);
298    if (num_ports > packet->ports_alloced)    if (num_ports > packet->ports_alloced)
299      {      {
300        mach_port_t *new_ports = malloc (sizeof (mach_port_t *) * num_ports);        mach_port_t *new_ports = malloc (sizeof (mach_port_t) * num_ports);
301        if (! new_ports)        if (! new_ports)
302          return ENOMEM;          return ENOMEM;
303        free (packet->ports);        free (packet->ports);
304          packet->ports = new_ports;
305        packet->ports_alloced = num_ports;        packet->ports_alloced = num_ports;
306      }      }
307    bcopy (ports, packet->ports, sizeof (mach_port_t *) * num_ports);    bcopy (ports, packet->ports, sizeof (mach_port_t) * num_ports);
308    packet->num_ports = num_ports;    packet->num_ports = num_ports;
309    return 0;    return 0;
310  }  }
# Line 312  error_t Line 315  error_t
315  packet_read_ports (struct packet *packet,  packet_read_ports (struct packet *packet,
316                     mach_port_t **ports, size_t *num_ports)                     mach_port_t **ports, size_t *num_ports)
317  {  {
318    int length = packet->num_ports * sizeof (mach_port_t *);    int length = packet->num_ports * sizeof (mach_port_t);
319    if (*num_ports < packet->num_ports)    if (*num_ports < packet->num_ports)
320      {      {
321        *ports = mmap (0, length, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);        *ports = mmap (0, length, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26