Changeset 2498b95 in mainline for uspace/lib/c/generic/mem.c
- Timestamp:
- 2018-06-25T15:49:26Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fbfe59d
- Parents:
- bfe90b6
- git-author:
- Jiri Svoboda <jiri@…> (2018-06-24 19:48:37)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-06-25 15:49:26)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/mem.c
rbfe90b6 r2498b95 1 1 /* 2 2 * Copyright (c) 2005 Martin Decky 3 * Copyright (c) 20 08 Jiri Svoboda3 * Copyright (c) 2018 Jiri Svoboda 4 4 * All rights reserved. 5 5 * … … 252 252 } 253 253 254 /** Search memory area. 255 * 256 * @param s Memory area 257 * @param c Character (byte) to search for 258 * @param n Size of memory area in bytes 259 * 260 * @return Pointer to the first occurrence of @a c in the first @a n 261 * bytes of @a s or @c NULL if not found. 262 */ 263 void *memchr(const void *s, int c, size_t n) 264 { 265 uint8_t *u = (uint8_t *) s; 266 unsigned char uc = (unsigned char) c; 267 size_t i; 268 269 for (i = 0; i < n; i++) { 270 if (u[i] == uc) 271 return (void *) &u[i]; 272 } 273 274 return NULL; 275 } 276 254 277 /** @} 255 278 */
Note:
See TracChangeset
for help on using the changeset viewer.