From a24df49241adc7c49dff777742d668f1d6c690ad Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 21 Jun 2016 16:30:18 -0700 Subject: [PATCH] Introduce glib style macros for allocating memory with type --- common/os_calls.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/os_calls.h b/common/os_calls.h index 6a7cd093..a843b2e7 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -25,6 +25,7 @@ #define NULL 0 #endif +#include #include "arch.h" #define g_tcp_can_recv g_sck_can_recv @@ -183,4 +184,10 @@ int APP_CC g_shmdt(const void *shmaddr); int APP_CC g_gethostname(char *name, int len); int APP_CC g_mirror_memcpy(void *dst, const void *src, int len); +/* glib-style wrappers */ +#define g_new(struct_type, n_structs) \ + (struct_type *) malloc(sizeof(struct_type) * (n_structs)) +#define g_new0(struct_type, n_structs) \ + (struct_type *) calloc((n_structs), sizeof(struct_type)) + #endif