Skip to content

Commit

Permalink
z_bytes: expose wrap and rename new to from_str
Browse files Browse the repository at this point in the history
  • Loading branch information
p-avital committed Jan 18, 2024
1 parent be4030b commit ed34bce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extern "C" {
#endif

/********* Data Types Handlers *********/
#define z_bytes_wrap _z_bytes_wrap

/**
* Constructs a :c:type:`z_string_t` departing from a ``const char *``.
* It is a loaned key expression that aliases ``value``.
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,11 @@ z_owned_bytes_map_t z_bytes_map_null(void);
#endif

/**
* Returns a view of `str` using `strlen`.
* Returns a view of `str` using `strlen` (this constructor should not be used on untrusted input).
*
* `str == NULL` will cause this to return `z_bytes_null()`
*/
z_bytes_t z_bytes_new(const char *str);
z_bytes_t z_bytes_from_str(const char *str);
/**
* Returns the gravestone value for `z_bytes_t`
*/
Expand Down
4 changes: 1 addition & 3 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,6 @@ int8_t z_bytes_map_iter(const z_owned_bytes_map_t *this_, z_attachment_iter_body
}
z_owned_bytes_map_t z_bytes_map_new(void) { return (z_owned_bytes_map_t){._inner = _z_bytes_pair_list_new()}; }

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
z_owned_bytes_map_t z_bytes_map_null(void) { return (z_owned_bytes_map_t){._inner = NULL}; }

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
z_bytes_t z_bytes_new(const char *str) {
return (z_bytes_t){.len = strlen(str), ._is_alloc = false, .start = (unsigned char *)str};
}
z_bytes_t z_bytes_from_str(const char *str) { return z_bytes_wrap((const uint8_t *)str, strlen(str)); }
z_bytes_t z_bytes_null(void) { return (z_bytes_t){.len = 0, ._is_alloc = false, .start = NULL}; }

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file
#endif

0 comments on commit ed34bce

Please sign in to comment.