Add support for cppcheck 2.17.0

cppcheck 2.17.0 adds checks that a NULL pointer returned from malloc() and
calloc() is not used.

We do this quite a lot.

I've addressed this by adding functions g_malloc_nofail() and
g_calloc_nofail() which either allocate memory or abort.
functions are now called in places where we are not making these
checks.

Many of these checks are in test programs or example programs.

I've modified the list16 module to handle out-of-memory conditions.
This commit is contained in:
matt335672
2025-02-24 11:36:02 +00:00
parent 3446614961
commit 2f46ef27a2
9 changed files with 190 additions and 62 deletions
+4
View File
@@ -90,6 +90,10 @@ typedef struct stream
do \
{ \
(_s) = (STREAM *) calloc(1, sizeof(STREAM)); \
if (!(_s)) \
{ \
abort(); \
} \
(_s)->data = (u8 *) calloc(1, (_len)); \
(_s)->p = (_s)->data; \
(_s)->size = (_len); \