blob: c22abca856cefc610f1e46deec5ba863d9af4f76 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/*
Copyright 2022 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/priv.h>
#include <zap/mem.h>
zap_sz zap_memcnt(void const * const _ptr,zap_sz const _sz,zap_sz const _num,zap_bool (* const _fn)(void const *)) {
unsigned char const * addr = _ptr;
zap_sz const numbyte = _num * _sz;
unsigned char const * const afterbuf = addr + numbyte;
zap_sz num = 0x0u;
for (;addr != afterbuf;addr += _sz) {
if (_fn(addr)) {
++num;
}
}
return num;
}
|