Ignore:
Timestamp:
2010-04-04T22:07:05Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
23de644
Parents:
9f10660f (diff), 73060801 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/socket/adt/measured_strings.c

    r9f10660f r3aae4e8  
    4343#include <ipc/ipc.h>
    4444
    45 #include "../err.h"
    46 #include "../modules.h"
    47 
    48 #include "measured_strings.h"
    49 
    50 /** Computes the lengths of the measured strings in the given array.
    51  *  @param[in] strings The measured strings array to be processed.
    52  *  @param[in] count The measured strings array size.
    53  *  @returns The computed sizes array.
    54  *  @returns NULL if there is not enough memory left.
    55  */
    56 size_t * prepare_lengths(const measured_string_ref strings, size_t count);
     45#include <net_err.h>
     46#include <net_modules.h>
     47#include <adt/measured_strings.h>
    5748
    5849measured_string_ref measured_string_create_bulk(const char * string, size_t length){
     
    157148}
    158149
     150/** Computes the lengths of the measured strings in the given array.
     151 *  @param[in] strings The measured strings array to be processed.
     152 *  @param[in] count The measured strings array size.
     153 *  @returns The computed sizes array.
     154 *  @returns NULL if there is not enough memory left.
     155 */
     156static size_t * prepare_lengths(const measured_string_ref strings, size_t count){
     157        size_t * lengths;
     158        size_t index;
     159        size_t length;
     160
     161        lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
     162        if(! lengths){
     163                return NULL;
     164        }
     165        length = 0;
     166        for(index = 0; index < count; ++ index){
     167                lengths[index] = strings[index].length;
     168                length += lengths[index] + 1;
     169        }
     170        lengths[count] = length;
     171        return lengths;
     172}
     173
    159174int measured_strings_reply(const measured_string_ref strings, size_t count){
    160175        ERROR_DECLARE;
     
    265280}
    266281
    267 size_t * prepare_lengths(const measured_string_ref strings, size_t count){
    268         size_t * lengths;
    269         size_t index;
    270         size_t length;
    271 
    272         lengths = (size_t *) malloc(sizeof(size_t) * (count + 1));
    273         if(! lengths){
    274                 return NULL;
    275         }
    276         length = 0;
    277         for(index = 0; index < count; ++ index){
    278                 lengths[index] = strings[index].length;
    279                 length += lengths[index] + 1;
    280         }
    281         lengths[count] = length;
    282         return lengths;
    283 }
    284 
    285282/** @}
    286283 */
Note: See TracChangeset for help on using the changeset viewer.