From 734e9935d2e5a01c432b99a4483706b976490125 Mon Sep 17 00:00:00 2001 From: dreamsource-tai Date: Mon, 29 Jul 2024 11:34:58 +0800 Subject: [PATCH] Updated the declaration regarding g_try_malloc(). --- libsigrokdecode4DSL/HACKING | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libsigrokdecode4DSL/HACKING b/libsigrokdecode4DSL/HACKING index 5dd8e2c1..d295ee52 100644 --- a/libsigrokdecode4DSL/HACKING +++ b/libsigrokdecode4DSL/HACKING @@ -41,8 +41,8 @@ Random notes - Generally avoid assigning values to variables at declaration time, especially so for complex and/or run-time dependent values. - - Consistently use g_*malloc() / g_*malloc0(). Do not use standard - g_try_malloc0()/calloc() if it can be avoided (sometimes other libs such + - Consistently use g_try_malloc0() / g_try_malloc(). Do not use standard + malloc() if it can be avoided (sometimes other libs such as libftdi can return g_try_malloc0()'d memory, for example). - Always properly match allocations with the proper *free() functions. If @@ -50,11 +50,11 @@ Random notes memory. Otherwise use standard g_free(). Never use the wrong function! - We assume that "small" memory allocations (< 1MB) will always succeed. - Thus, it's fine to use g_try_malloc0() or g_try_malloc0() for allocations of - simple/small structs and such (instead of using g_try_malloc0()), and + Thus, it's fine to use g_try_malloc0() or g_try_malloc() for allocations of + simple/small structs and such (instead of using malloc()), and there's no need to check the return value. - Do use g_try_malloc0() or g_try_malloc0() for large (>= 1MB) allocations + Do use g_try_malloc0() or g_try_malloc() for large (>= 1MB) allocations and check the return value. - You should never print any messages (neither to stdout nor stderr nor