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:
parent
1893013260
commit
4d9b4412bd
@ -18,6 +18,7 @@ extern "C" {
|
||||
extern void *memchr(const void *source, int value, 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 *memccpy(void *dest, const void *source, int stopByte, size_t length);
|
||||
extern void *memmove(void *dest, const void *source, size_t length);
|
||||
extern void *memset(void *dest, int value, size_t length);
|
||||
|
||||
|
@ -5,6 +5,7 @@ KernelMergeObject posix_string.o :
|
||||
bcopy.c
|
||||
bzero.c
|
||||
ffs.cpp
|
||||
memccpy.c
|
||||
memchr.c
|
||||
memcmp.c
|
||||
memcpy.c
|
||||
|
27
src/system/libroot/posix/string/memccpy.c
Normal file
27
src/system/libroot/posix/string/memccpy.c
Normal 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user