apply some corrections

This commit is contained in:
Nadia Holmquist Pedersen 2024-05-15 16:29:28 +02:00
parent e33cbb4018
commit e29f42c937
2 changed files with 40 additions and 10 deletions

View File

@ -83,9 +83,8 @@ gchar* g_strdup(const gchar* str) {
int g_strv_length(GStrv strings) { int g_strv_length(GStrv strings) {
gint count = 0; gint count = 0;
while (count++) { while (strings[count])
if (strings[count] == NULL) break; count++;
}
return count; return count;
} }

View File

@ -30,21 +30,52 @@
#define GLIB_CHECK_VERSION(x, y, z) 1 #define GLIB_CHECK_VERSION(x, y, z) 1
#define G_STATIC_ASSERT(...) #define G_STATIC_ASSERT(...)
#define g_assert assert #define g_assert assert
#define G_UNLIKELY #define G_UNLIKELY(x) __builtin_expect(x, 0)
#define G_LIKELY
#define g_assert_not_reached() {} #define g_return_if_fail(expr) \
#define g_warn_if_reached() {} do { \
#define g_warn_if_fail(cond) {} if (!(expr)) \
#define g_return_val_if_fail(cond, val) if (!(cond)) return (val) return; \
#define g_return_if_fail(cond) if (!(cond)) return; } while (false)
#define g_return_val_if_fail(expr, val) \
do { \
if (!(expr)) \
return (val); \
} while (false)
#define g_warn_if_reached() \
do { \
g_warning("g_warn_if_reached: Reached " __FILE__ ":%d", __LINE__); \
} while (false)
#define g_warn_if_fail(expr) \
do { \
if (!(expr)) \
g_warning("g_warn_if_fail: Expression '" #expr "' failed at " __FILE__ ":%d", __LINE__); \
} while (false)
#define g_assert_not_reached() \
do { \
assert(false && "g_assert_not_reached"); \
__builtin_unreachable(); \
} while (false)
#define GLIB_SIZEOF_VOID_P 8 #define GLIB_SIZEOF_VOID_P 8
#ifndef MAX
#define MAX(a, b) (a > b ? a : b) #define MAX(a, b) (a > b ? a : b)
#endif
#ifndef MIN
#define MIN(a, b) (a < b ? a : b) #define MIN(a, b) (a < b ? a : b)
#endif
#ifndef TRUE
#define TRUE true #define TRUE true
#endif
#ifndef FALSE
#define FALSE false #define FALSE false
#endif
typedef bool gboolean; typedef bool gboolean;
typedef char gchar; typedef char gchar;