/* 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 #include 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; }