in reply to Re^3: OT: Why does malloc always give me 24?
in thread OT: Why does malloc always give me 24? [SOLVED]
”… why…do something silly like that”
It’s not me, the library works like this:
struct _host { int status; str name; }; typedef struct _host host; void host_free(host *); host host_copy(host *); #define T host // <- custom type #include <deq.h> // functions to implement void host_free(host *h) { str_free(&h->name); } host host_copy(host *h) { host _ = *h; _.name = str_copy(&h->name); return _; }
The library then provides:
container_type_push_back container_type_pop_back container_type_push_front container_type_pop_front
…and some more, depending on the container.
If the container is a deq (dequeue) and its type named fubar this would result in deq_fubar_push_back and so on. Instead of a simple push in a well know post-modern language. One may regret this but it is like it is. And I don't know how else to do it. Apart from the fact that I can't write such macros.
Other libraries, like m*lib work similiar - m*lib does this excessively.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: OT: Why does malloc always give me 24?
by NERDVANA (Priest) on Aug 20, 2024 at 06:43 UTC | |
by karlgoethebier (Abbot) on Aug 20, 2024 at 08:49 UTC | |
by NERDVANA (Priest) on Aug 20, 2024 at 23:19 UTC | |
by karlgoethebier (Abbot) on Aug 21, 2024 at 13:11 UTC | |
by NERDVANA (Priest) on Aug 23, 2024 at 22:07 UTC | |
|