Mercurial > molko
comparison libmlk-core/mlk/core/util.h @ 629:fee7bd30725c
rpg: cleanup tileset-loader-file
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 26 Aug 2023 16:09:35 +0200 |
parents | 509b395171f2 |
children | 3d238b43a9aa |
comparison
equal
deleted
inserted
replaced
628:c2b62ff38224 | 629:fee7bd30725c |
---|---|
22 /** | 22 /** |
23 * \file mlk/core/util.h | 23 * \file mlk/core/util.h |
24 * \brief libmlk-core utilities | 24 * \brief libmlk-core utilities |
25 */ | 25 */ |
26 | 26 |
27 #include <stddef.h> | |
27 #include <stdint.h> | 28 #include <stdint.h> |
28 | 29 |
29 /** | 30 /** |
30 * Compute the length of an fixed size array. | 31 * Compute the length of an fixed size array. |
31 * | 32 * |
32 * \param x the fixed size array | 33 * \param x the fixed size array |
33 * \return the length | 34 * \return the length |
34 */ | 35 */ |
35 #define MLK_UTIL_SIZE(x) (sizeof ((x)) / sizeof ((x)[0])) | 36 #define MLK_UTIL_SIZE(x) (sizeof ((x)) / sizeof ((x)[0])) |
37 | |
38 /** | |
39 * Obtain parent container from a member field. | |
40 */ | |
41 #define MLK_CONTAINER_OF(ptr, type, member) \ | |
42 ((type*)((char*)(1 ? (ptr) : &((type*)0)->member) - offsetof(type, member))) | |
36 | 43 |
37 #if defined(__cplusplus) | 44 #if defined(__cplusplus) |
38 extern "C" { | 45 extern "C" { |
39 #endif | 46 #endif |
40 | 47 |