Skip to content

Instantly share code, notes, and snippets.

View thass0's full-sized avatar
🔬
Oh no, my memory is leaking!

Thassilo Schulze thass0

🔬
Oh no, my memory is leaking!
View GitHub Profile
@thass0
thass0 / Lapce.desktop.md
Created December 31, 2023 11:44
Logo configuration for the .desktop file of the Lapce editor (lapce.dev)

Lapce.desktop

The base .desktop for Lapce file can be found here

For logos to work, download either the light app logo or the dark app logo and save it in the icons directory inside one of the directories contained in the $XDG_DATA_DIRS environment variable.

For example, /usr/local/share/ is part of $XDG_DATA_DIRS on my machine, so

@thass0
thass0 / 0-c-arrays.md
Last active October 7, 2023 08:32
Using heap-allocated and bound-check arrays in C

The following programs demonstrate how VLAs can be used in some pretty cool ways in C. They allow creating dynamic array types, with information about the size of the array being known only at runtime.

  • The first example shows how this kind of information can be attached to VLAs which are completely heap-allocated, and never touch the stack.
  • In the second example, the information attached to the type of the array is used in combination with UBSan to check for out of bounds access to the array at runtime!
  • Lastly, the third example demonstrates why we have to use this weird special syntax to correctly dereference and access pointers to VLAs.

Examples two and three make use of the fact that classic, fixed-size C arrays are interoperable with VLAs. That is, given a fixed-size array, we're able to pass it and its its size to a function that expects a VLA.