use standard ARRAY_SIZE() macro

Replace all the custom `sizeof(array)/sizeof(element)` and
`sizeof(array)/sizeof(type)` with the standard macro ARRAY_SIZE().
This commit is contained in:
Eric Engestrom 2018-07-30 14:29:34 +01:00
parent 5f8676f214
commit 021933f735
14 changed files with 33 additions and 23 deletions

View file

@ -1,6 +1,7 @@
#include <stdint.h>
#include <stddef.h>
#include "unicode.h"
#include "util.h"
size_t utf8_chsize(uint32_t ch) {
if (ch < 0x80) {
@ -92,7 +93,7 @@ static const struct {
int utf8_size(const char *s) {
uint8_t c = (uint8_t)*s;
for (size_t i = 0; i < sizeof(sizes) / sizeof(*sizes); ++i) {
for (size_t i = 0; i < ARRAY_SIZE(sizes); ++i) {
if ((c & sizes[i].mask) == sizes[i].result) {
return sizes[i].octets;
}