📄 memchr.c
字号:
/*************************************************************************
*
* Copyright Mentor Graphics Corporation 2002
* All Rights Reserved.
*
* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
* SUBJECT TO LICENSE TERMS.
*
*************************************************************************/
/*************************************************************************
* FILE NAME VERSION
*
* memchr.c Nucleus Common Library 1.1
*
* DESCRIPTION
*
* This file contains the implementation of NCL_memchr.
*
* DATA STRUCTURES
*
* None.
*
* FUNCTIONS
*
* NCL_memchr
*
* DEPENDENCIES
*
* ncl.h
* string.h
* nucleus.h
*
************************************************************************/
#define NU_NCL_SOURCE_FILE
#include "ncl\inc\ncl.h"
#include "ncl\inc\string.h"
#include "plus\nucleus.h" /* MMU Support */
/*************************************************************************
*
* FUNCTION
*
* NCL_strchr
*
* DESCRIPTION
*
* Return a pointer to first occurrence of c in s or 0 if s does not
* contain c. If c==0 it returns a pointer to the string's nul
* character.
*
* INPUTS
*
* s Memory to search within.
* c Values to search for.
* n Number of bytes to search.
*
* OUTPUTS
*
* void* Pointer to first occurance of c in s or 0 if
* s does not contain c.
*
*************************************************************************/
void *NCL_memchr (const void *s, int c, size_t n)
{
register unsigned char val = (unsigned char) c;
register unsigned char *ptr = (unsigned char*) s;
register unsigned char *end = ptr + n;
while (ptr < end)
{
if (*ptr++ == val)
{
return ((void*) (ptr-1));
}
}
return (NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -