Added memccpy() - not there in BeOS, but part of the POSIX specs.

Contributed by Alexander Deynichenko.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14592 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-10-31 12:18:55 +00:00
parent 1893013260
commit 4d9b4412bd
3 changed files with 29 additions and 0 deletions

View File

@ -18,6 +18,7 @@ extern "C" {
extern void *memchr(const void *source, int value, size_t length); extern void *memchr(const void *source, int value, size_t length);
extern int memcmp(const void *buffer1, const void *buffer2, size_t length); extern int memcmp(const void *buffer1, const void *buffer2, size_t length);
extern void *memcpy(void *dest, const void *source, size_t length); extern void *memcpy(void *dest, const void *source, size_t length);
extern void *memccpy(void *dest, const void *source, int stopByte, size_t length);
extern void *memmove(void *dest, const void *source, size_t length); extern void *memmove(void *dest, const void *source, size_t length);
extern void *memset(void *dest, int value, size_t length); extern void *memset(void *dest, int value, size_t length);

View File

@ -5,6 +5,7 @@ KernelMergeObject posix_string.o :
bcopy.c bcopy.c
bzero.c bzero.c
ffs.cpp ffs.cpp
memccpy.c
memchr.c memchr.c
memcmp.c memcmp.c
memcpy.c memcpy.c

View File

@ -0,0 +1,27 @@
/*
* Copyright 2005, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT license.
*/
#include <SupportDefs.h>
#include <string.h>
void *
memccpy(void *_dest, const void *_source, int stopByte, size_t length)
{
if (length) {
const uint8 *source = (const uint8 *)_source;
uint8 *dest = (uint8 *)_dest;
do {
if ((*dest++ = *source++) == (uint8)stopByte)
return dest;
} while (--length != 0);
}
return NULL;
}