Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Mar 4, 2024
1 parent a16d84c commit 5216d7a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions include/zenoh-pico/collections/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand All @@ -58,15 +58,15 @@
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; \
} \
static inline void name##_array_free(name##_array_t **a) { \
name##_array_t *ptr = *a; \
if (ptr != NULL) { \
name##_array_clear(ptr); \
z_free(ptr); \
z_free(ptr); \
*a = NULL; \
} \
}
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/collections/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
} \
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/collections/intmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
} \
} \
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh-pico/collections/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand All @@ -136,7 +136,7 @@
} \
_ZP_RC_OP_SYNC \
type##_clear(&p->in->val); \
z_free(p->in); \
z_free(p->in); \
return true; \
}

Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/system/platform/mbed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
} \
Expand All @@ -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); \
} \
Expand All @@ -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); \
} \
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 5216d7a

Please sign in to comment.