Changeset 59ecd4a in mainline for uspace/lib/socket/adt/measured_strings.c
- Timestamp:
- 2010-04-04T21:41:47Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5db9084
- Parents:
- 36a75a2 (diff), ee7e82a9 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/socket/adt/measured_strings.c
r36a75a2 r59ecd4a 43 43 #include <ipc/ipc.h> 44 44 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> 57 48 58 49 measured_string_ref measured_string_create_bulk(const char * string, size_t length){ … … 157 148 } 158 149 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 */ 156 static 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 159 174 int measured_strings_reply(const measured_string_ref strings, size_t count){ 160 175 ERROR_DECLARE; … … 265 280 } 266 281 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 285 282 /** @} 286 283 */
Note:
See TracChangeset
for help on using the changeset viewer.