From 5216d7a421b6fbee3727d184c8999b4df71993b9 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Mon, 4 Mar 2024 11:07:27 +0100 Subject: [PATCH] fix format --- include/zenoh-pico/collections/array.h | 6 +++--- include/zenoh-pico/collections/element.h | 4 ++-- include/zenoh-pico/collections/intmap.h | 2 +- include/zenoh-pico/collections/refcount.h | 8 ++++---- include/zenoh-pico/system/platform/mbed.h | 2 +- src/api/api.c | 6 +++--- src/protocol/codec.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/zenoh-pico/collections/array.h b/include/zenoh-pico/collections/array.h index db4335205..fe2b3f306 100644 --- a/include/zenoh-pico/collections/array.h +++ b/include/zenoh-pico/collections/array.h @@ -33,7 +33,7 @@ } \ static inline name##_array_t name##_array_make(size_t capacity) { \ name##_array_t a; \ - a._val = (type *)z_malloc(capacity * sizeof(type)); \ + a._val = (type *)z_malloc(capacity * sizeof(type)); \ if (a._val != NULL) { \ a._len = capacity; \ } else { \ @@ -58,7 +58,7 @@ for (size_t i = 0; i < a->_len; i++) { \ name##_elem_clear(&a->_val[i]); \ } \ - z_free(a->_val); \ + z_free(a->_val); \ a->_len = 0; \ a->_val = NULL; \ } \ @@ -66,7 +66,7 @@ name##_array_t *ptr = *a; \ if (ptr != NULL) { \ name##_array_clear(ptr); \ - z_free(ptr); \ + z_free(ptr); \ *a = NULL; \ } \ } diff --git a/include/zenoh-pico/collections/element.h b/include/zenoh-pico/collections/element.h index aa78481cc..96a62e4eb 100644 --- a/include/zenoh-pico/collections/element.h +++ b/include/zenoh-pico/collections/element.h @@ -35,13 +35,13 @@ typedef _Bool (*z_element_eq_f)(const void *left, const void *right); type *ptr = (type *)*e; \ if (ptr != NULL) { \ elem_clear_f(ptr); \ - z_free(ptr); \ + z_free(ptr); \ *e = NULL; \ } \ } \ static inline void name##_elem_copy(void *dst, const void *src) { elem_copy_f((type *)dst, (type *)src); } \ static inline void *name##_elem_clone(const void *src) { \ - type *dst = (type *)z_malloc(elem_size_f((type *)src)); \ + type *dst = (type *)z_malloc(elem_size_f((type *)src)); \ if (dst != NULL) { \ elem_copy_f(dst, (type *)src); \ } \ diff --git a/include/zenoh-pico/collections/intmap.h b/include/zenoh-pico/collections/intmap.h index ba927599a..caa54e035 100644 --- a/include/zenoh-pico/collections/intmap.h +++ b/include/zenoh-pico/collections/intmap.h @@ -70,7 +70,7 @@ void _z_int_void_map_free(_z_int_void_map_t **map, z_element_free_f f); name##_intmap_entry_t *ptr = (name##_intmap_entry_t *)*e; \ if (ptr != NULL) { \ name##_elem_free(&ptr->_val); \ - z_free(ptr); \ + z_free(ptr); \ *e = NULL; \ } \ } \ diff --git a/include/zenoh-pico/collections/refcount.h b/include/zenoh-pico/collections/refcount.h index 9b48a9d45..de12ffdea 100644 --- a/include/zenoh-pico/collections/refcount.h +++ b/include/zenoh-pico/collections/refcount.h @@ -94,7 +94,7 @@ } name##_rc_t; \ static inline name##_rc_t name##_rc_new(void) { \ name##_rc_t p; \ - p.in = (name##_inner_rc_t *)z_malloc(sizeof(name##_inner_rc_t)); \ + p.in = (name##_inner_rc_t *)z_malloc(sizeof(name##_inner_rc_t)); \ if (p.in != NULL) { \ memset(&p.in->val, 0, sizeof(type##_t)); \ _ZP_RC_OP_INIT_CNT \ @@ -103,7 +103,7 @@ } \ static inline name##_rc_t name##_rc_new_from_val(type##_t val) { \ name##_rc_t p; \ - p.in = (name##_inner_rc_t *)z_malloc(sizeof(name##_inner_rc_t)); \ + p.in = (name##_inner_rc_t *)z_malloc(sizeof(name##_inner_rc_t)); \ if (p.in != NULL) { \ p.in->val = val; \ _ZP_RC_OP_INIT_CNT \ @@ -117,7 +117,7 @@ return c; \ } \ static inline name##_rc_t *name##_rc_clone_as_ptr(name##_rc_t *p) { \ - name##_rc_t *c = (name##_rc_t *)z_malloc(sizeof(name##_rc_t)); \ + name##_rc_t *c = (name##_rc_t *)z_malloc(sizeof(name##_rc_t)); \ if (c != NULL) { \ c->in = p->in; \ _ZP_RC_OP_INCR_CNT \ @@ -136,7 +136,7 @@ } \ _ZP_RC_OP_SYNC \ type##_clear(&p->in->val); \ - z_free(p->in); \ + z_free(p->in); \ return true; \ } diff --git a/include/zenoh-pico/system/platform/mbed.h b/include/zenoh-pico/system/platform/mbed.h index ee6de7d81..170b230f3 100644 --- a/include/zenoh-pico/system/platform/mbed.h +++ b/include/zenoh-pico/system/platform/mbed.h @@ -27,7 +27,7 @@ typedef void *z_task_t; // Workaround as MBED is a C++ library typedef void *z_task_attr_t; // Workaround as MBED is a C++ library typedef void *z_mutex_t; // Workaround as MBED is a C++ library typedef void *z_condvar_t; // Workaround as MBED is a C++ library -#endif // Z_FEATURE_MULTI_THREAD == 1 +#endif // Z_FEATURE_MULTI_THREAD == 1 typedef void *z_clock_t; // Not defined typedef struct timeval z_time_t; diff --git a/src/api/api.c b/src/api/api.c index 55fb851ba..1c1660be5 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -348,7 +348,7 @@ void z_closure_zid_call(const z_owned_closure_zid_t *closure, const z_id_t *id) ownedtype *z_##name##_move(ownedtype *val) { return val; } \ ownedtype z_##name##_clone(ownedtype *val) { \ ownedtype ret; \ - ret._value = (type *)z_malloc(sizeof(type)); \ + ret._value = (type *)z_malloc(sizeof(type)); \ if (ret._value != NULL) { \ f_copy(ret._value, val->_value); \ } \ @@ -369,7 +369,7 @@ void z_closure_zid_call(const z_owned_closure_zid_t *closure, const z_id_t *id) #define OWNED_FUNCTIONS_PTR_CLONE(type, ownedtype, name, f_copy) \ ownedtype z_##name##_clone(ownedtype *val) { \ ownedtype ret; \ - ret._value = (_##type *)z_malloc(sizeof(_##type)); \ + ret._value = (_##type *)z_malloc(sizeof(_##type)); \ if (ret._value != NULL) { \ f_copy(ret._value, val->_value); \ } \ @@ -391,7 +391,7 @@ void z_closure_zid_call(const z_owned_closure_zid_t *closure, const z_id_t *id) ownedtype z_##name##_clone(ownedtype *val) { \ ownedtype ret; \ size_t size = _z_str_size(val->_value); \ - ret._value = (_##type)z_malloc(size); \ + ret._value = (_##type)z_malloc(size); \ if (ret._value != NULL) { \ f_copy(ret._value, val->_value, size); \ } \ diff --git a/src/protocol/codec.c b/src/protocol/codec.c index 0ab81ea1b..65e13ec07 100644 --- a/src/protocol/codec.c +++ b/src/protocol/codec.c @@ -362,7 +362,7 @@ int8_t _z_str_decode(char **str, _z_zbuf_t *zbf) { _z_zint_t len = 0; ret |= _z_zint_decode(&len, zbf); if (ret == _Z_RES_OK) { - if (_z_zbuf_len(zbf) >= len) { // Check if we have enough bytes to read + if (_z_zbuf_len(zbf) >= len) { // Check if we have enough bytes to read char *tmp = (char *)z_malloc(len + (size_t)1); // Allocate space for the string terminator if (tmp != NULL) { tmp[len] = '\0';