summaryrefslogtreecommitdiff
path: root/zap/source/any/mem/srch.c
blob: 46c8ec80d0c56619e0c4db87515f790417ef462d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
	Copyright 2022-2023 Gabriel Jensen.
	This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
	If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/

#include <zap/mem.h>

void * zap_srch(void const * const voidbuf,zap_i8 const val,zap_sz const num) {
	unsigned char const *       buf  = voidbuf;
	unsigned char const * const stop = buf + num;
	while (buf != stop) {
		unsigned char const * addr = buf++;
		if (*addr == val) return (void *)addr;
	}
	return zap_nullptr;
}