10 Commits

Author SHA1 Message Date
Alejandro Colomar
0d9193dcf6 lib/: Rename XMALLOC() => xmalloc_T()
The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-12-05 21:22:45 -06:00
Alejandro Colomar
0afe216953 lib/: Rename MALLOC() => malloc_T()
The 'T' in the name notes that this API is a type-safe variant of the
API it wraps.  This makes the names more explicative.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-12-05 21:22:45 -06:00
Alejandro Colomar
9705effba5 lib/: Use compound literals to avoid casts
Casts are unsafe.

Compound literals also have the ability of converting values, but they
don't have the unwanted effects on safety --casts disable most useful
diagnostics--.

Compound literals are lvalues, which means their address can be taken,
and they can also be assigned to.  To avoid this, we force lvalue
conversion through a statement expression.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-12-05 21:22:45 -06:00
Alejandro Colomar
2f18e7c0b6 lib/{alloc,search}/: Use typeas() to add support for arbitrary types
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-12-05 08:34:32 -06:00
Alejandro Colomar
97380c811a lib/: Use a consistent name for macro arguments representing a type name
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-12-05 08:34:32 -06:00
Alejandro Colomar
655ffcbe1b lib/, src/, tests/: Move x*() definitions to non-x* header files
Now that all of these are one-liners, they don't need a separate header
file.  Compact stuff.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-10-27 14:32:06 +01:00
Evgeny Grin (Karlson2k)
eb71706b1c */: Fix including <config.h> as system header
"config.h" is a locally generated header. It must be included as
'#include "config.h"'.
It is already included correctly in some sources files. This commit
unifies the way how "config.h" is included.

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
2025-07-16 14:12:40 +02:00
Alejandro Colomar
ba3a51e90f lib/: Use [[gnu::alloc_size(...)]] on allocation functions
Suggested-by: Martin Uecker <uecker@tugraz.at>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-07-01 21:40:11 -05:00
Alejandro Colomar
5111e5ed1b lib/: Use multi-line macro definitions
This reduces the complexity of those nested parentheses.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-07-01 21:40:11 -05:00
Alejandro Colomar
3049bef9c3 lib/alloc/, lib/, src/, tests/: Organize the allocation APIs in a new subdirectory
Signed-off-by: Alejandro Colomar <alx@kernel.org>
2024-07-01 21:40:11 -05:00