Changeset 2498b95 in mainline for uspace/lib/posix/src/string.c


Ignore:
Timestamp:
2018-06-25T15:49:26Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
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)
Message:

Move memchr to libc and add tests for other memxxx functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/src/string.c

    rbfe90b6 r2498b95  
    288288
    289289        return 0;
    290 }
    291 
    292 /**
    293  * Find byte in memory.
    294  *
    295  * @param mem Memory area in which to look for the byte.
    296  * @param c Byte to look for.
    297  * @param n Maximum number of bytes to be inspected.
    298  * @return Pointer to the specified byte on success,
    299  *     NULL pointer otherwise.
    300  */
    301 void *memchr(const void *mem, int c, size_t n)
    302 {
    303         assert(mem != NULL);
    304 
    305         const unsigned char *s = mem;
    306 
    307         for (size_t i = 0; i < n; ++i) {
    308                 if (s[i] == (unsigned char) c) {
    309                         return (void *) &s[i];
    310                 }
    311         }
    312         return NULL;
    313290}
    314291
Note: See TracChangeset for help on using the changeset viewer.