Reactos
at master 48 lines 1.3 kB view raw
1/*** 2*memccpy.c - copy bytes until a character is found 3* 4* Copyright (c) Microsoft Corporation. All rights reserved. 5* 6*Purpose: 7* defines _memccpy() - copies bytes until a specifed character 8* is found, or a maximum number of characters have been copied. 9* 10*******************************************************************************/ 11 12#include <string.h> 13 14/*** 15*char *_memccpy(dest, src, c, count) - copy bytes until character found 16* 17*Purpose: 18* Copies bytes from src to dest until count bytes have been 19* copied, or up to and including the character c, whichever 20* comes first. 21* 22*Entry: 23* void *dest - pointer to memory to receive copy 24* void *src - source of bytes 25* int c - character to stop copy at 26* size_t count - max number of bytes to copy 27* 28*Exit: 29* returns pointer to byte immediately after c in dest 30* returns NULL if c was never found 31* 32*Exceptions: 33* 34*******************************************************************************/ 35 36void * __cdecl _memccpy ( 37 void * dest, 38 const void * src, 39 int c, 40 size_t count 41 ) 42{ 43 while ( count && (*((char *)(dest = (char *)dest + 1) - 1) = 44 *((char *)(src = (char *)src + 1) - 1)) != (char)c ) 45 count--; 46 47 return(count ? dest : NULL); 48}