blob: 0192d0f747f4ecd1ee8f17524d98271691d5ddf9 [file] [log] [blame]
Imre Kisb2e06a02024-05-28 16:50:50 +02001/*
2 * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stddef.h>
8#include <string.h>
9
10char *strstr(const char *haystack, const char *needle)
11{
12 const char *h = NULL;
13 size_t needle_len = 0;
14
15 if (needle[0] == '\0')
16 return (char *)haystack;
17
18 needle_len = strlen(needle);
19 for (h = haystack; (h = strchr(h, needle[0])) != 0; h++)
20 if (strncmp(h, needle, needle_len) == 0)
21 return (char *)h;
22
23 return NULL;
24}