diff -r 000000000000 -r e4d67989cc36 genericopenlibs/cstdlib/LCHAR/MEMCHR.C --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/genericopenlibs/cstdlib/LCHAR/MEMCHR.C Tue Feb 02 02:01:42 2010 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* FUNCTION +* <>---find character in memory +* INDEX +* memchr +* ANSI_SYNOPSIS +* #include +* void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); +* TRAD_SYNOPSIS +* #include +* void *memchr(<[src]>, <[c]>, <[length]>) +* void *<[src]>; +* void *<[c]>; +* size_t <[length]>; +* This function searches memory starting at <<*<[src]>>> for the +* character <[c]>. The search only ends with the first +* occurrence of <[c]>, or after <[length]> characters; in +* particular, <> does not terminate the search. +* RETURNS +* If the character <[c]> is found within <[length]> characters +* of <<*<[src]>>>, a pointer to the character is returned. If +* <[c]> is not found, then <> is returned. +* PORTABILITY +* <>> is ANSI C. +* <> requires no supporting OS subroutines. +* QUICKREF +* memchr ansi pure +* +* +*/ + + + +#include <_ansi.h> +#include + +/** +Search buffer for a character. +Searches the first num bytes of memory block pointed by src_void for character c. +@return A pointer to the first occurrence of c in buffer. +If character is not found the function returns NULL. +@param src_void Pointer to buffer. +@param c Key character to look for. +@param length Number of characters to check from buffer. +*/ +EXPORT_C void * +memchr (const void* src_void, int c, size_t length) +{ + const unsigned char *src = (const unsigned char *) src_void; + + while (length--) + { + if (*src == c) + return (char *) src; + src++; + } + return NULL; +}