Changes in uspace/lib/c/generic/mem.c [1433ecda:2498b95] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/mem.c
r1433ecda 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.