summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-02-14 11:05:57 -0500
committer AJR <ajrhacker@users.noreply.github.com>2021-02-14 11:05:57 -0500
commitbc0146c2038c46f789a246d5616afd7c425157f3 (patch)
treeb4d39194034b4c6e56ccd4035d25636034be43ca /src/lib
parent91310bcdeb7ab0ff661738b212017bf836f4e8ad (diff)
Eliminate ARRAY_LENGTH template in favor of C++17's std::size
* osdcomm.h: Move definition of EQUIVALENT_ARRAY to coretmpl.h * sharc.cpp, gt64xxx.cpp, ym2413.cpp, gb_lcd.cpp, snes_ppu.cpp: Use STRUCT_MEMBER for save state registration * gio/newport.cpp, megadrive/svp.cpp, nes_ctrl/bcbattle.cpp, arm7.cpp, tms9995.cpp, pckeybrd.cpp, sa1110.cpp, sa1111.cpp, jangou_blitter.cpp, vic4567.cpp: Use std::fill(_n) instead of memset * emucore.h: Remove obsolete typedef
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/formats/ap2_dsk.cpp2
-rw-r--r--src/lib/formats/ap_dsk35.cpp22
-rw-r--r--src/lib/formats/cassimg.cpp4
-rw-r--r--src/lib/formats/cassimg.h1
-rw-r--r--src/lib/formats/flopimg.cpp2
-rw-r--r--src/lib/formats/p2000t_cas.cpp4
-rw-r--r--src/lib/formats/pc_dsk.cpp2
-rw-r--r--src/lib/util/chd.cpp8
-rw-r--r--src/lib/util/chdcodec.cpp4
-rw-r--r--src/lib/util/corefile.cpp8
-rw-r--r--src/lib/util/coretmpl.h10
-rw-r--r--src/lib/util/flac.cpp8
-rw-r--r--src/lib/util/flac.h20
-rw-r--r--src/lib/util/options.cpp3
-rw-r--r--src/lib/util/plaparse.cpp6
-rw-r--r--src/lib/util/png.cpp6
-rw-r--r--src/lib/util/pool.cpp10
-rw-r--r--src/lib/util/unicode.cpp2
18 files changed, 66 insertions, 56 deletions
diff --git a/src/lib/formats/ap2_dsk.cpp b/src/lib/formats/ap2_dsk.cpp
index 1a2e2a65e68..84b87a06e47 100644
--- a/src/lib/formats/ap2_dsk.cpp
+++ b/src/lib/formats/ap2_dsk.cpp
@@ -67,7 +67,7 @@ static const uint8_t *get_untranslate6_map(void)
if (!map_inited)
{
memset(map, 0xff, sizeof(map));
- for (i = 0; i < ARRAY_LENGTH(translate6); i++)
+ for (i = 0; i < std::size(translate6); i++)
map[translate6[i]] = i;
map_inited = 1;
}
diff --git a/src/lib/formats/ap_dsk35.cpp b/src/lib/formats/ap_dsk35.cpp
index 235d9f3d0c2..cecf105c189 100644
--- a/src/lib/formats/ap_dsk35.cpp
+++ b/src/lib/formats/ap_dsk35.cpp
@@ -225,7 +225,7 @@ int apple35_sectors_per_track(floppy_image_legacy *image, int track)
int sectors;
assert(track >= 0);
- assert(track < ARRAY_LENGTH(apple35_tracklen_800kb));
+ assert(track < std::size(apple35_tracklen_800kb));
if (get_apple35_tag(image)->is_1440k)
sectors = 18;
@@ -454,7 +454,7 @@ static uint32_t apple35_get_offset(floppy_image_legacy *floppy, int head, int tr
tag = get_apple35_tag(floppy);
- if (track >= ARRAY_LENGTH(apple35_tracklen_800kb))
+ if (track >= std::size(apple35_tracklen_800kb))
return ~0;
if (head >= tag->sides)
return ~0;
@@ -616,7 +616,7 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
tag = get_apple35_tag(floppy);
- if (track >= ARRAY_LENGTH(apple35_tracklen_800kb))
+ if (track >= std::size(apple35_tracklen_800kb))
return FLOPPY_ERROR_SEEKERROR;
if (offset != 0)
return FLOPPY_ERROR_UNSUPPORTED;
@@ -628,7 +628,7 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
for (sector = 0; sector < sector_count; sector++)
{
/* read the sector */
- err = apple35_read_sector_td(floppy, head, track, sector, sector_data, ARRAY_LENGTH(sector_data));
+ err = apple35_read_sector_td(floppy, head, track, sector, sector_data, std::size(sector_data));
if (err)
{
return err;
@@ -636,7 +636,7 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
sony_nibblize35(sector_data, nibble_data, checksum);
- for (i = 0; i < ARRAY_LENGTH(blk1); i++)
+ for (i = 0; i < std::size(blk1); i++)
sony_filltrack((uint8_t*)buffer, buflen, &pos, blk1[i]);
sum = (track ^ sector ^ side ^ tag->format_byte) & 0x3F;
@@ -647,18 +647,18 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[tag->format_byte]);
sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[sum]);
- for (i = 0; i < ARRAY_LENGTH(blk2); i++)
+ for (i = 0; i < std::size(blk2); i++)
sony_filltrack((uint8_t*)buffer, buflen, &pos, blk2[i]);
sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[sector]);
- for (i = 0; i < ARRAY_LENGTH(nibble_data); i++)
+ for (i = 0; i < std::size(nibble_data); i++)
sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[nibble_data[i]]);
for (i = 3; i >= 0; i--)
sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[checksum[i]]);
- for (i = 0; i < ARRAY_LENGTH(blk3); i++)
+ for (i = 0; i < std::size(blk3); i++)
sony_filltrack((uint8_t*)buffer, buflen, &pos, blk3[i]);
}
@@ -681,7 +681,7 @@ static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int
tag = get_apple35_tag(floppy);
- if (track >= ARRAY_LENGTH(apple35_tracklen_800kb))
+ if (track >= std::size(apple35_tracklen_800kb))
return FLOPPY_ERROR_SEEKERROR;
if (offset != 0)
return FLOPPY_ERROR_UNSUPPORTED;
@@ -756,7 +756,7 @@ static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int
continue;
j++;
- for (i = 0; i < ARRAY_LENGTH(nibble_data); i++)
+ for (i = 0; i < std::size(nibble_data); i++)
{
nibble_data[i] = rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)];
j++;
@@ -778,7 +778,7 @@ static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int
sony_denibblize35(sector_data, nibble_data, checksum);
/* write the sector */
- err = apple35_write_sector_td(floppy, head, track, sector, sector_data, ARRAY_LENGTH(sector_data), 0);
+ err = apple35_write_sector_td(floppy, head, track, sector, sector_data, std::size(sector_data), 0);
if (err)
return err;
diff --git a/src/lib/formats/cassimg.cpp b/src/lib/formats/cassimg.cpp
index ee271abc8a7..527bfc884fb 100644
--- a/src/lib/formats/cassimg.cpp
+++ b/src/lib/formats/cassimg.cpp
@@ -94,12 +94,12 @@ const int8_t *choose_wave(const cassette_image::Modulation &modulation, size_t &
if (modulation.flags & cassette_image::MODULATION_SINEWAVE)
{
- wave_bytes_length = ARRAY_LENGTH(sine_wave);
+ wave_bytes_length = std::size(sine_wave);
return sine_wave;
}
else
{
- wave_bytes_length = ARRAY_LENGTH(square_wave);
+ wave_bytes_length = std::size(square_wave);
return square_wave;
}
}
diff --git a/src/lib/formats/cassimg.h b/src/lib/formats/cassimg.h
index 09f6aaa0099..3a59870571a 100644
--- a/src/lib/formats/cassimg.h
+++ b/src/lib/formats/cassimg.h
@@ -14,7 +14,6 @@
#include "ioprocs.h"
-#include "coretmpl.h"
#include "osdcore.h"
#include <memory>
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp
index 9322551124b..cb8d6ca1300 100644
--- a/src/lib/formats/flopimg.cpp
+++ b/src/lib/formats/flopimg.cpp
@@ -876,7 +876,7 @@ const char *floppy_error(floperr_t err)
"Required parameter not specified"
};
- if ((err < 0) || (err >= ARRAY_LENGTH(error_messages)))
+ if ((err < 0) || (err >= std::size(error_messages)))
return nullptr;
return error_messages[err];
}
diff --git a/src/lib/formats/p2000t_cas.cpp b/src/lib/formats/p2000t_cas.cpp
index 7bc0c6b21a9..de6652d41ad 100644
--- a/src/lib/formats/p2000t_cas.cpp
+++ b/src/lib/formats/p2000t_cas.cpp
@@ -3,6 +3,8 @@
#include "p2000t_cas.h"
+#include "coretmpl.h" // BIT
+
#include <cassert>
#include <ostream>
@@ -294,7 +296,7 @@ static cassette_image::error p2000t_cas_load(cassette_image *cassette)
// Insert sync header.. 0xAA, 0x00, 0x00, 0xAA
CHR(p2000t_silence(cassette, &time_idx, P2000_BOB_GAP));
- CHR(p2000t_put_bytes(cassette, &time_idx, &unused, BLOCK_MARK, ARRAY_LENGTH(BLOCK_MARK)));
+ CHR(p2000t_put_bytes(cassette, &time_idx, &unused, BLOCK_MARK, std::size(BLOCK_MARK)));
CHR(p2000t_silence(cassette, &time_idx, P2000_MARK_GAP));
// Insert data block
diff --git a/src/lib/formats/pc_dsk.cpp b/src/lib/formats/pc_dsk.cpp
index 75e05f87654..ef9efce3bf3 100644
--- a/src/lib/formats/pc_dsk.cpp
+++ b/src/lib/formats/pc_dsk.cpp
@@ -48,7 +48,7 @@ static floperr_t pc_dsk_compute_geometry(floppy_image_legacy *floppy, struct bas
memset(geometry, 0, sizeof(*geometry));
size = floppy_image_size(floppy);
- for (i = 0; i < ARRAY_LENGTH(disk_sizes); i++)
+ for (i = 0; i < std::size(disk_sizes); i++)
{
if (disk_sizes[i].image_size == size)
{
diff --git a/src/lib/util/chd.cpp b/src/lib/util/chd.cpp
index 7d3e2c7c5c8..0de05849cdd 100644
--- a/src/lib/util/chd.cpp
+++ b/src/lib/util/chd.cpp
@@ -1626,7 +1626,7 @@ chd_error chd_file::codec_configure(chd_codec_type codec, int param, void *confi
try
{
// find the codec and call its configuration
- for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compression); codecnum++)
+ for (int codecnum = 0; codecnum < std::size(m_compression); codecnum++)
if (m_compression[codecnum] == codec)
{
m_decompressor[codecnum]->configure(param, config);
@@ -2453,7 +2453,7 @@ chd_error chd_file::open_common(bool writeable)
void chd_file::create_open_common()
{
// verify the compression types and initialize the codecs
- for (int decompnum = 0; decompnum < ARRAY_LENGTH(m_compression); decompnum++)
+ for (int decompnum = 0; decompnum < std::size(m_compression); decompnum++)
{
m_decompressor[decompnum] = chd_codec_list::new_decompressor(m_compression[decompnum], *this);
if (m_decompressor[decompnum] == nullptr && m_compression[decompnum] != 0)
@@ -3071,7 +3071,7 @@ void *chd_file_compressor::async_compress_hunk_static(void *param, int threadid)
void chd_file_compressor::async_compress_hunk(work_item &item, int threadid)
{
// use our thread's codec
- assert(threadid < ARRAY_LENGTH(m_codecs));
+ assert(threadid < std::size(m_codecs));
item.m_codecs = m_codecs[threadid];
// compute CRC-16 and SHA-1 hashes
@@ -3278,7 +3278,7 @@ uint64_t chd_file_compressor::hashmap::find(util::crc16_t crc16, util::sha1_t sh
void chd_file_compressor::hashmap::add(uint64_t itemnum, util::crc16_t crc16, util::sha1_t sha1)
{
// add to the appropriate map
- if (m_block_list->m_nextalloc == ARRAY_LENGTH(m_block_list->m_array))
+ if (m_block_list->m_nextalloc == std::size(m_block_list->m_array))
m_block_list = new entry_block(m_block_list);
entry_t *entry = &m_block_list->m_array[m_block_list->m_nextalloc++];
entry->m_itemnum = itemnum;
diff --git a/src/lib/util/chdcodec.cpp b/src/lib/util/chdcodec.cpp
index 7f6e0f018cd..4f5c23b3104 100644
--- a/src/lib/util/chdcodec.cpp
+++ b/src/lib/util/chdcodec.cpp
@@ -622,7 +622,7 @@ chd_compressor_group::chd_compressor_group(chd_file &chd, uint32_t compressor_li
#endif
{
// verify the compression types and initialize the codecs
- for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compressor); codecnum++)
+ for (int codecnum = 0; codecnum < std::size(m_compressor); codecnum++)
{
m_compressor[codecnum] = nullptr;
if (compressor_list[codecnum] != CHD_CODEC_NONE)
@@ -663,7 +663,7 @@ int8_t chd_compressor_group::find_best_compressor(const uint8_t *src, uint8_t *c
// determine best compression technique
complen = m_hunkbytes;
int8_t compression = -1;
- for (int codecnum = 0; codecnum < ARRAY_LENGTH(m_compressor); codecnum++)
+ for (int codecnum = 0; codecnum < std::size(m_compressor); codecnum++)
if (m_compressor[codecnum] != nullptr)
{
// attempt to compress, swallowing errors
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp
index 1149035045a..8cb8deea8f2 100644
--- a/src/lib/util/corefile.cpp
+++ b/src/lib/util/corefile.cpp
@@ -462,7 +462,7 @@ int core_text_file::getc()
{
// place the new character in the ring buffer
m_back_char_head = 0;
- m_back_char_tail = utf8_from_uchar(m_back_chars, ARRAY_LENGTH(m_back_chars), uchar);
+ m_back_char_tail = utf8_from_uchar(m_back_chars, std::size(m_back_chars), uchar);
//assert(file->back_char_tail != -1);
}
}
@@ -473,7 +473,7 @@ int core_text_file::getc()
else
{
result = m_back_chars[m_back_char_head++];
- m_back_char_head %= ARRAY_LENGTH(m_back_chars);
+ m_back_char_head %= std::size(m_back_chars);
}
return result;
@@ -488,7 +488,7 @@ int core_text_file::getc()
int core_text_file::ungetc(int c)
{
m_back_chars[m_back_char_tail++] = char(c);
- m_back_char_tail %= ARRAY_LENGTH(m_back_chars);
+ m_back_char_tail %= std::size(m_back_chars);
return c;
}
@@ -577,7 +577,7 @@ int core_text_file::puts(std::string_view s)
*pconvbuf++ = ch;
// if we overflow, break into chunks
- if (pconvbuf >= convbuf + ARRAY_LENGTH(convbuf) - 10)
+ if (pconvbuf >= convbuf + std::size(convbuf) - 10)
{
count += write(convbuf, pconvbuf - convbuf);
pconvbuf = convbuf;
diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h
index 438f7134fd2..18b64e7c0ff 100644
--- a/src/lib/util/coretmpl.h
+++ b/src/lib/util/coretmpl.h
@@ -535,6 +535,16 @@ std::basic_string_view<CharT, Traits> buf_to_string_view(basic_ovectorstream<Cha
}
+// For declaring an array of the same dimensions as another array (including multi-dimensional arrays)
+template <typename T, typename U> struct equivalent_array_or_type { typedef T type; };
+template <typename T, typename U, std::size_t N> struct equivalent_array_or_type<T, U[N]> { typedef typename equivalent_array_or_type<T, U>::type type[N]; };
+template <typename T, typename U> using equivalent_array_or_type_t = typename equivalent_array_or_type<T, U>::type;
+template <typename T, typename U> struct equivalent_array { };
+template <typename T, typename U, std::size_t N> struct equivalent_array<T, U[N]> { typedef equivalent_array_or_type_t<T, U> type[N]; };
+template <typename T, typename U> using equivalent_array_t = typename equivalent_array<T, U>::type;
+#define EQUIVALENT_ARRAY(a, T) util::equivalent_array_t<T, std::remove_reference_t<decltype(a)> >
+
+
template <typename E>
using enable_enum_t = typename std::enable_if_t<std::is_enum<E>::value, typename std::underlying_type_t<E> >;
diff --git a/src/lib/util/flac.cpp b/src/lib/util/flac.cpp
index 5b912b89279..13bf7aed8eb 100644
--- a/src/lib/util/flac.cpp
+++ b/src/lib/util/flac.cpp
@@ -10,7 +10,7 @@
#include "flac.h"
-#include "osdcomm.h"
+#include "corefile.h"
#include <cassert>
#include <new>
@@ -129,7 +129,7 @@ bool flac_encoder::encode_interleaved(const int16_t *samples, uint32_t samples_p
// process in batches of 2k samples
FLAC__int32 converted_buffer[2048];
FLAC__int32 *dest = converted_buffer;
- uint32_t cur_samples = (std::min<size_t>)(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
+ uint32_t cur_samples = (std::min<size_t>)(std::size(converted_buffer) / num_channels, samples_per_channel);
// convert a buffers' worth
for (uint32_t sampnum = 0; sampnum < cur_samples; sampnum++)
@@ -162,7 +162,7 @@ bool flac_encoder::encode(int16_t *const *samples, uint32_t samples_per_channel,
// process in batches of 2k samples
FLAC__int32 converted_buffer[2048];
FLAC__int32 *dest = converted_buffer;
- uint32_t cur_samples = (std::min<size_t>)(ARRAY_LENGTH(converted_buffer) / num_channels, samples_per_channel);
+ uint32_t cur_samples = (std::min<size_t>)(std::size(converted_buffer) / num_channels, samples_per_channel);
// convert a buffers' worth
for (uint32_t sampnum = 0; sampnum < cur_samples; sampnum++, srcindex++)
@@ -464,7 +464,7 @@ bool flac_decoder::decode(int16_t **samples, uint32_t num_samples, bool swap_end
{
// make sure we don't have too many channels
int chans = channels();
- if (chans > ARRAY_LENGTH(m_uncompressed_start))
+ if (chans > std::size(m_uncompressed_start))
return false;
// configure the uncompressed buffer
diff --git a/src/lib/util/flac.h b/src/lib/util/flac.h
index 2b814437cd5..ad667320b41 100644
--- a/src/lib/util/flac.h
+++ b/src/lib/util/flac.h
@@ -13,15 +13,17 @@
#pragma once
-#include "corefile.h"
-
#include <FLAC/all.h>
+#include <cstdint>
+
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
+namespace util { class core_file; }
+
// ======================> flac_encoder
class flac_encoder
@@ -64,18 +66,18 @@ private:
// internal state
FLAC__StreamEncoder * m_encoder; // actual encoder
util::core_file * m_file; // output file
- uint32_t m_compressed_offset; // current offset with the compressed stream
+ uint32_t m_compressed_offset; // current offset with the compressed stream
FLAC__byte * m_compressed_start; // start of compressed data
- uint32_t m_compressed_length; // length of the compressed stream
-
+ uint32_t m_compressed_length; // length of the compressed stream
+
// parameters
- uint32_t m_sample_rate; // sample rate
- uint8_t m_channels; // number of channels
- uint32_t m_block_size; // block size
+ uint32_t m_sample_rate; // sample rate
+ uint8_t m_channels; // number of channels
+ uint32_t m_block_size; // block size
// header stripping
bool m_strip_metadata; // strip the metadata?
- uint32_t m_ignore_bytes; // how many bytes to ignore when writing
+ uint32_t m_ignore_bytes; // how many bytes to ignore when writing
bool m_found_audio; // have we hit the audio yet?
};
diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp
index e1674a88fe1..bf1a4e45b20 100644
--- a/src/lib/util/options.cpp
+++ b/src/lib/util/options.cpp
@@ -12,7 +12,6 @@
#include "corefile.h"
#include "corestr.h"
-#include "osdcomm.h"
#include <locale>
#include <string>
@@ -732,7 +731,7 @@ void core_options::parse_ini_file(util::core_file &inifile, int priority, bool i
// loop over lines in the file
char buffer[4096];
- while (inifile.gets(buffer, ARRAY_LENGTH(buffer)) != nullptr)
+ while (inifile.gets(buffer, std::size(buffer)) != nullptr)
{
// find the extent of the name
char *optionname;
diff --git a/src/lib/util/plaparse.cpp b/src/lib/util/plaparse.cpp
index 76fbbad6983..09b7724375e 100644
--- a/src/lib/util/plaparse.cpp
+++ b/src/lib/util/plaparse.cpp
@@ -12,8 +12,6 @@
#include "plaparse.h"
-#include "osdcomm.h"
-
#include <cstdio>
#include <cstdlib>
#include <cstring>
@@ -214,11 +212,11 @@ static bool process_field(jed_data *data, const uint8_t **src, const uint8_t *sr
// find keyword
char dest[0x10];
- memset(dest, 0, ARRAY_LENGTH(dest));
+ memset(dest, 0, sizeof(dest));
const uint8_t *seek = *src;
int destptr = 0;
- while (seek < srcend && isalpha(*seek) && destptr < ARRAY_LENGTH(dest) - 1)
+ while (seek < srcend && isalpha(*seek) && destptr < sizeof(dest) - 1)
{
dest[destptr] = tolower(*seek);
seek++;
diff --git a/src/lib/util/png.cpp b/src/lib/util/png.cpp
index 67e3366606b..0605206bbf1 100644
--- a/src/lib/util/png.cpp
+++ b/src/lib/util/png.cpp
@@ -123,7 +123,7 @@ private:
png_error process(std::list<image_data_chunk> const &idata)
{
// do some basic checks for unsupported images
- if (!pnginfo.bit_depth || (ARRAY_LENGTH(samples) <= pnginfo.color_type) || !samples[pnginfo.color_type])
+ if (!pnginfo.bit_depth || (std::size(samples) <= pnginfo.color_type) || !samples[pnginfo.color_type])
return png_error::UNSUPPORTED_FORMAT; // unknown colour format
if ((0 != pnginfo.interlace_method) && (1 != pnginfo.interlace_method))
return png_error::UNSUPPORTED_FORMAT; // unknown interlace method
@@ -474,7 +474,7 @@ public:
// do some basic checks for unsupported images
if ((8 > pnginfo.bit_depth) || (pnginfo.bit_depth % 8))
return png_error::UNSUPPORTED_FORMAT; // only do multiples of 8bps here - expand lower bit depth first
- if ((ARRAY_LENGTH(samples) <= pnginfo.color_type) || !samples[pnginfo.color_type])
+ if ((std::size(samples) <= pnginfo.color_type) || !samples[pnginfo.color_type])
return png_error::UNSUPPORTED_FORMAT; // unknown colour sample format
if ((0 != pnginfo.interlace_method) && (1 != pnginfo.interlace_method))
return png_error::UNSUPPORTED_FORMAT; // unknown interlace method
@@ -721,7 +721,7 @@ public:
static png_error verify_header(core_file &fp)
{
- EQUIVALENT_ARRAY(PNG_SIGNATURE, std::uint8_t) signature;
+ std::uint8_t signature[sizeof(PNG_SIGNATURE)];
// read 8 bytes
if (fp.read(signature, sizeof(signature)) != sizeof(signature))
diff --git a/src/lib/util/pool.cpp b/src/lib/util/pool.cpp
index faf1de170ae..509c4f76984 100644
--- a/src/lib/util/pool.cpp
+++ b/src/lib/util/pool.cpp
@@ -14,8 +14,8 @@
#include "osdcomm.h"
#include <cstdarg>
-#include <cstddef>
#include <cstdlib>
+#include <iterator>
/***************************************************************************
@@ -35,7 +35,7 @@
struct objtype_entry
{
objtype_entry * next;
- uint32_t type;
+ uint32_t type;
const char * friendly;
void (*destructor)(void *, size_t);
};
@@ -296,7 +296,7 @@ void *pool_object_add_file_line(object_pool *pool, object_type _type, void *obje
pool->blocklist = block;
/* add all entries to the free list */
- for (entrynum = 0; entrynum < ARRAY_LENGTH(block->entry); entrynum++)
+ for (entrynum = 0; entrynum < std::size(block->entry); entrynum++)
{
block->entry[entrynum].next = pool->freelist;
pool->freelist = &block->entry[entrynum];
@@ -615,8 +615,8 @@ bool test_memory_pools()
/* some heavier stress tests */
for (i = 0; i < 512; i++)
{
- ptrs[i % ARRAY_LENGTH(ptrs)] = pool_realloc_lib(pool,
- ptrs[i % ARRAY_LENGTH(ptrs)], rand() % 1000);
+ ptrs[i % std::size(ptrs)] = pool_realloc_lib(pool,
+ ptrs[i % std::size(ptrs)], rand() % 1000);
}
pool_free_lib(pool);
diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp
index de6ef06e5c9..c4ee6c56cde 100644
--- a/src/lib/util/unicode.cpp
+++ b/src/lib/util/unicode.cpp
@@ -384,7 +384,7 @@ int utf8_from_uchar(char *utf8string, size_t count, char32_t uchar)
std::string utf8_from_uchar(char32_t uchar)
{
char buffer[UTF8_CHAR_MAX];
- auto len = utf8_from_uchar(buffer, ARRAY_LENGTH(buffer), uchar);
+ auto len = utf8_from_uchar(buffer, std::size(buffer), uchar);
return std::string(buffer, len);
}