headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / string / memccpy.c
blobfbe49704134d27ec924c7210edfc2d2d89d4cc2a
1 /*
2 * Copyright 2005, Haiku Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT license.
4 */
7 #include <SupportDefs.h>
9 #include <string.h>
12 void *
13 memccpy(void *_dest, const void *_source, int stopByte, size_t length)
15 if (length) {
16 const uint8 *source = (const uint8 *)_source;
17 uint8 *dest = (uint8 *)_dest;
19 do {
20 if ((*dest++ = *source++) == (uint8)stopByte)
21 return dest;
22 } while (--length != 0);
25 return NULL;