1//===-- Implementation of wmemchr -----------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "src/wchar/wmemchr.h"
10
11#include "hdr/types/size_t.h"
12#include "hdr/types/wchar_t.h"
13#include "src/__support/common.h"
14#include "src/__support/macros/config.h"
15
16namespace LIBC_NAMESPACE_DECL {
17
18LLVM_LIBC_FUNCTION(const wchar_t *, wmemchr,
19 (const wchar_t *s, wchar_t c, size_t n)) {
20 size_t i = 0;
21 for (; i < n; ++i)
22 if (s[i] == c)
23 return (s + i);
24 return nullptr;
25}
26
27} // namespace LIBC_NAMESPACE_DECL
28

source code of libc/src/wchar/wmemchr.cpp