Тёмный

Zig Master: Introduction to Allocators 

Dude the Builder
Подписаться 3,6 тыс.
Просмотров 2,2 тыс.
50% 1

Help me create more content like this!
www.paypal.com...
Allocating on the heap is performed via allocators in Zig. This is one of the distinctive features of Zig as a language, and in this episode we take a whirlwind tour of the basic use of an allocator. We also see some sample functions that take allocators to produce their output.
The code: codeberg.org/d...
Relevant Links:
ziglang.org/do...
Thumbnail artwork courtesy of: www.deviantart...

Опубликовано:

 

13 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 9   
@thilina91
@thilina91 20 дней назад
thanks for the great video about zig allocators.
@rodriidamn98
@rodriidamn98 2 месяца назад
Thanks for the content ❤
@binitrupakheti4246
@binitrupakheti4246 3 месяца назад
Confused about the str_out. Didn't we already free that inside the asBytes function?
@dudethebuilder
@dudethebuilder 3 месяца назад
In asBytes, the ArrayList collects the bytes in its items array allocated on the heap. When we call toOwnedSlice, that array of bytes on the heap is detached from the list and returned from asBytes. So when the defer deinit for the list kicks in, the list is already empty. It's now the responsibility of the caller of asBytes to free the returned bytes. Basically, the list just serves as a convenient temporary mechanism to collect the bytes on the heap.
@noel6857
@noel6857 3 месяца назад
@@dudethebuilder I think he's talking about the `const code_points_out_2 = try asCodePoints(str_out, &buf);` line. Although the result is the same in the end, it would have been more consistent to use *str_in* as the first argument, i.e. `const code_points_out_2 = try asCodePoints(str_in, &buf);`. After all, you did use its length to define the size of the buffer that's used as the second argument. In any case, thanks for the tutorial!
@dudethebuilder
@dudethebuilder 3 месяца назад
Good eye! That's totally true. I fixed the code and pushed the new version. Thank you for clarifying.
@YuruCampSupermacy
@YuruCampSupermacy 3 месяца назад
hi whats the difference between zig master and zig in depth series? both the names sound similar
@dudethebuilder
@dudethebuilder 3 месяца назад
Zig in Depth was made when Zig version 0.11 was the stable version. Aside from the build system and some command changes, the language itself is mostly the same so the videos are still relevant. Zig Master is covering the latest versions of Zig.
@YuruCampSupermacy
@YuruCampSupermacy 3 месяца назад
@@dudethebuilder thanks, love the series, thanks for creating it.
Далее
Zig Master: Let's Create a Stack!
36:23
Просмотров 1,4 тыс.
Zig for Impatient Devs
9:48
Просмотров 94 тыс.
А я с первого раза прошла (2024)
01:00
Learn Linked Lists In C
45:18
Просмотров 1
What's a Memory Allocator Anyway? - Benjamin Feng
48:30
Why I Chose Rust Over Zig
33:18
Просмотров 188 тыс.
10 weird algorithms
9:06
Просмотров 1,2 млн
Implementing a Lox interpreter in Rust
7:53:42
Просмотров 46 тыс.
Programming Procedural Animations
32:46
Просмотров 4 тыс.
Zig Master: Let's Create a Trie!
17:14
Просмотров 2,1 тыс.