Changeset 1e2e0c1e in mainline for uspace/srv/net/structures


Ignore:
Timestamp:
2010-02-17T21:15:03Z (16 years ago)
Author:
Lukas Mejdrech <lukasmejdrech@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6b7b198
Parents:
bfd7aac
Message:
  • change in the pq_add interface
Location:
uspace/srv/net/structures/packet
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/structures/packet/packet.c

    rbfd7aac r1e2e0c1e  
    184184}
    185185
    186 packet_t pq_add( packet_t first, packet_t packet, size_t order, size_t metric ){
     186int pq_add( packet_t * first, packet_t packet, size_t order, size_t metric ){
    187187        packet_t        item;
    188188
    189         if( ! packet_is_valid( packet )) return NULL;
     189        if(( ! first ) || ( ! packet_is_valid( packet ))) return EINVAL;
    190190        pq_set_order( packet, order, metric );
    191         if( packet_is_valid( first )){
    192                 item = first;
     191        if( packet_is_valid( * first )){
     192                item = * first;
    193193                do{
    194194                        if( item->order < order ){
     
    198198                                        item->next = packet->packet_id;
    199199                                        packet->previous = item->packet_id;
    200                                         return first;
     200                                        return EOK;
    201201                                }
    202202                        }else{
     
    205205                                item->previous = packet->packet_id;
    206206                                item = pm_find( packet->previous );
    207                                 if( item ) item->next = packet->packet_id;
    208                                 return item ? first : packet;
     207                                if( item ){
     208                                        item->next = packet->packet_id;
     209                                }else{
     210                                        * first = packet;
     211                                }
     212                                return EOK;
    209213                        }
    210214                }while( packet_is_valid( item ));
    211215        }
    212         return packet;
     216        * first = packet;
     217        return EOK;
    213218}
    214219
  • uspace/srv/net/structures/packet/packet.h

    rbfd7aac r1e2e0c1e  
    8686 *  The queue is sorted in the ascending order.
    8787 *  The packet is inserted right before the packets of the same order value.
    88  *  @param[in] first The first packet of the queue. May be NULL.
     88 *  @param[in,out] first The first packet of the queue. Sets the first packet of the queue. The original first packet may be shifted by the new packet.
    8989 *  @param[in] packet The packet to be added.
    9090 *  @param[in] order The packet order value.
    9191 *  @param[in] metric The metric value of the packet.
    92  *  @returns The first packet of the queue. The original first packet may be shifted by the new packet.
    93  *  @returns NULL if the packet is not valid.
     92 *  @returns EOK on success.
     93 *  @returns EINVAL if the first parameter is NULL.
     94 *  @returns EINVAL if the packet is not valid.
    9495 */
    95 packet_t        pq_add( packet_t first, packet_t packet, size_t order, size_t metric );
     96int     pq_add( packet_t * first, packet_t packet, size_t order, size_t metric );
    9697
    9798/** Finds the packet with the given order.
  • uspace/srv/net/structures/packet/packet_server.c

    rbfd7aac r1e2e0c1e  
    229229void packet_release( packet_t packet ){
    230230        int index;
     231        int result;
    231232
    232233        // remove debug dump
    233234//      printf( "packet %d released\n", packet->packet_id );
    234235        for( index = 0; ( index < FREE_QUEUES_COUNT - 1 ) && ( packet->length > ps_globals.sizes[ index ] ); ++ index );
    235         ps_globals.free[ index ] = pq_add( ps_globals.free[ index ], packet, packet->length, packet->length );
    236         assert( ps_globals.free[ index ] );
     236        result = pq_add( & ps_globals.free[ index ], packet, packet->length, packet->length );
     237        assert( result == EOK );
    237238}
    238239
Note: See TracChangeset for help on using the changeset viewer.