Mercurial > molko
comparison doc/docs/dev/ownership.md @ 366:19782ea1cf4a
misc: start rebranding
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 24 Oct 2021 15:57:42 +0200 |
parents | 97f55f6b9593 |
children |
comparison
equal
deleted
inserted
replaced
365:06badab52877 | 366:19782ea1cf4a |
---|---|
1 # Howto: ownership and memory management | 1 # Howto: ownership and memory management |
2 | 2 |
3 How memory and ownership is used within Molko's Adventure API. | 3 How memory and ownership is used within Molko's Engine API. |
4 | 4 |
5 ## Synopsis | 5 ## Synopsis |
6 | 6 |
7 In C, memory management can be a cumbersome issue and a major common complain | 7 In C, memory management can be a cumbersome issue and a major common complain |
8 when it comes to leak. | 8 when it comes to leak. |
15 | 15 |
16 You can imagine a situation with a DVD player and some movies on DVDs. You have | 16 You can imagine a situation with a DVD player and some movies on DVDs. You have |
17 one DVD player where you put some DVDs inside but the DVD player never make its | 17 one DVD player where you put some DVDs inside but the DVD player never make its |
18 own copy, it simply reads your disc and you get it back afterwards. | 18 own copy, it simply reads your disc and you get it back afterwards. |
19 | 19 |
20 Following this philosophy, the Molko's Adventure API for this scenario would | 20 Following this philosophy, the Molko's Engine API for this scenario would |
21 look like this: | 21 look like this: |
22 | 22 |
23 ```c | 23 ```c |
24 struct dvd_player player; | 24 struct dvd_player player; |
25 struct dvd dvd; | 25 struct dvd dvd; |
117 user for both reading/writing. The field `th` is an optional non-owning pointer | 117 user for both reading/writing. The field `th` is an optional non-owning pointer |
118 to a theme which is also readable/writable. The field `elapsed` is readable but | 118 to a theme which is also readable/writable. The field `elapsed` is readable but |
119 should not be modified. Finally, the field `text` is private and should not be | 119 should not be modified. Finally, the field `text` is private and should not be |
120 touched by the user. | 120 touched by the user. |
121 | 121 |
122 ## Memory handling in Molko's Adventure API | 122 ## Memory handling in Molko's Engine API |
123 | 123 |
124 | | Dynamic allocation? | Notes | | 124 | | Dynamic allocation? | Notes | |
125 |-------------|-----------------------------|---------------------------------------------------------| | 125 |-------------|-----------------------------|---------------------------------------------------------| |
126 | libmlk-core | None | The util.h provides convenient allocators for the user. | | 126 | libmlk-core | None | The util.h provides convenient allocators for the user. | |
127 | libmlk-ui | None | | | 127 | libmlk-ui | None | | |