<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/xmalloc.c, branch master</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=master</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2026-07-21T09:00:54Z</updated>
<entry>
<title>xmalloc/xsnprintf: simplify some code with new FATAL_ERROR_ON() macro</title>
<updated>2026-07-21T09:00:54Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2026-07-12T13:33:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c8a4fc6e7ab9ac0e3194b61a966da2df4f050ba0'/>
<id>urn:sha1:c8a4fc6e7ab9ac0e3194b61a966da2df4f050ba0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>xmalloc: avoid using reallocarray(3) to implement xreallocarray()</title>
<updated>2026-07-21T09:00:52Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2026-07-13T10:48:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=da7bdf8ab7dc999009b6b83d3354066c18ec4f38'/>
<id>urn:sha1:da7bdf8ab7dc999009b6b83d3354066c18ec4f38</id>
<content type='text'>
See the added comment for reasoning.

The reallocarray(3) function in libc could have been used conditionally,
when available, but since it can be implemented simply and efficiently,
the portable version may just as well be used in all cases.

See also:

* https://pubs.opengroup.org/onlinepubs/9799919799/functions/reallocarray.html#:~:text=adding-,reallocarray
* https://android.googlesource.com/platform/bionic/+/HEAD/docs/status.md#:~:text=reallocarray
* https://github.com/termux/termux-packages/tree/26826aec834182c/x11-packages/foot
* https://github.com/termux/termux-packages/blob/26826aec834182c/x11-packages/foot/reallocarray.c#L6
* https://github.com/termux/termux-packages/blob/26826aec834182c/x11-packages/foot/xmalloc.c.patch#L7
* https://github.com/termux/termux-packages/pull/17818
* https://github.com/termux/termux-packages/issues/23833 (see expanded build log)
</content>
</entry>
<entry>
<title>xmalloc: calling xrealloc() or xreallocarray() with a 0-size is UB in C23</title>
<updated>2025-02-05T12:35:17Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-02-03T07:31:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f718cb3fb0d627cab8d952b94891e38238934090'/>
<id>urn:sha1:f718cb3fb0d627cab8d952b94891e38238934090</id>
<content type='text'>
And likely to in future POSIX too.
</content>
</entry>
<entry>
<title>xmalloc: add xreallocarray()</title>
<updated>2025-02-05T12:35:16Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-01-30T08:06:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=aae794e9bdd5f19019560041479cf7ebc46b4fa5'/>
<id>urn:sha1:aae794e9bdd5f19019560041479cf7ebc46b4fa5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>terminal: simplify some string-related code in reload_fonts()</title>
<updated>2024-01-23T22:04:41Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2024-01-23T20:33:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6ed1c28d2c5209c0149ff222ec2f96369bab7308'/>
<id>urn:sha1:6ed1c28d2c5209c0149ff222ec2f96369bab7308</id>
<content type='text'>
</content>
</entry>
<entry>
<title>fcft: adapt to API changes in fcft-3.x</title>
<updated>2022-02-05T16:00:54Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-08-21T12:50:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e0227266cabc015c282774ac898e3f52dce943df'/>
<id>urn:sha1:e0227266cabc015c282774ac898e3f52dce943df</id>
<content type='text'>
Fcft no longer uses wchar_t, but plain uint32_t to represent
codepoints.

Since we do a fair amount of string operations in foot, it still makes
sense to use something that actually _is_ a string (or character),
rather than an array of uint32_t.

For this reason, we switch out all wchar_t usage in foot to
char32_t. We also verify, at compile-time, that char32_t used
UTF-32 (which is what fcft expects).

Unfortunately, there are no string functions for char32_t. To avoid
having to re-implement all wcs*() functions, we add a small wrapper
layer of c32*() functions.

These wrapper functions take char32_t arguments, but then simply call
the corresponding wcs*() function.

For this to work, wcs*() must _also_ be UTF-32 compatible. We can
check for the presence of the  __STDC_ISO_10646__ macro. If set,
wchar_t is at least 4 bytes and its internal representation is UTF-32.

FreeBSD does *not* define this macro, because its internal wchar_t
representation depends on the current locale. It _does_ use UTF-32
_if_ the current locale is UTF-8.

Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is
defined.

Other fcft API changes:

* fcft_glyph_rasterize() -&gt; fcft_codepoint_rasterize()
* font.space_advance has been removed
* ‘tags’ have been removed from fcft_grapheme_rasterize()
* ‘fcft_log_init()’ removed
* ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
</content>
</entry>
<entry>
<title>xmalloc: export xvasprintf()</title>
<updated>2021-05-07T14:52:56Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-05-07T14:41:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7af475098b48b3338b884f738e7360ad55d4a14d'/>
<id>urn:sha1:7af475098b48b3338b884f738e7360ad55d4a14d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>debug: make use of log_msg() in fatal_error() and bug() functions</title>
<updated>2021-02-09T12:32:33Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2021-02-09T12:32:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7656744877f55658c205b1c5d2bf76651def10b2'/>
<id>urn:sha1:7656744877f55658c205b1c5d2bf76651def10b2</id>
<content type='text'>
Instead of writing directly to stderr and/or syslog(3).
</content>
</entry>
<entry>
<title>debug: rename assert() to xassert(), to avoid clashing with &lt;assert.h&gt;</title>
<updated>2021-01-16T20:16:00Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2021-01-16T20:16:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e56136ce1192d04a52b01ccb41284f0b7896430e'/>
<id>urn:sha1:e56136ce1192d04a52b01ccb41284f0b7896430e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Print stack trace on assert() failure or when calling fatal_error()</title>
<updated>2021-01-16T19:56:33Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2021-01-15T20:39:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=22f25a9e4feddbc093ae01cd53bdda3c2c3a82e9'/>
<id>urn:sha1:22f25a9e4feddbc093ae01cd53bdda3c2c3a82e9</id>
<content type='text'>
Note: this uses the __sanitizer_print_stack_trace() function from the
AddressSanitizer runtime, so it only works when AddressSanitizer is
in use.
</content>
</entry>
<entry>
<title>xmalloc: add xwcsdup()</title>
<updated>2020-10-09T17:43:04Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2020-10-09T17:43:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8aba25a477b91bfae213a8247e364bf4e7cddb69'/>
<id>urn:sha1:8aba25a477b91bfae213a8247e364bf4e7cddb69</id>
<content type='text'>
</content>
</entry>
<entry>
<title>xmalloc: fix edge case handling in xcalloc() function</title>
<updated>2020-08-25T19:49:24Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-25T19:49:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fe9eaf3aafe11428d630bb52bdfa5963f8f456b0'/>
<id>urn:sha1:fe9eaf3aafe11428d630bb52bdfa5963f8f456b0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>xmalloc: add xrealloc() and xstrndup() functions</title>
<updated>2020-08-07T00:05:04Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-07T00:05:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4564c8251353af6caf9c1bb8125377f4579dc596'/>
<id>urn:sha1:4564c8251353af6caf9c1bb8125377f4579dc596</id>
<content type='text'>
</content>
</entry>
<entry>
<title>xmalloc: log error to syslog() in fatal_error() function</title>
<updated>2020-08-05T19:11:51Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-05T19:11:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=014019e98da7fa0f7476bea5b6f3c84dafe7558a'/>
<id>urn:sha1:014019e98da7fa0f7476bea5b6f3c84dafe7558a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>config: handle allocation failure explicitly</title>
<updated>2020-08-04T22:28:16Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2020-08-04T22:28:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f1fce96a1d8026474b2cd56a855fd001cfd108b6'/>
<id>urn:sha1:f1fce96a1d8026474b2cd56a855fd001cfd108b6</id>
<content type='text'>
</content>
</entry>
</feed>
