mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
string: Reformat
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
6fc1bf6901
commit
5d27f69494
31
src/string.c
31
src/string.c
@@ -84,9 +84,10 @@ struct ssh_string_struct *ssh_string_new(size_t size)
|
||||
*
|
||||
* @return 0 on success, < 0 on error.
|
||||
*/
|
||||
int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len) {
|
||||
if ((s == NULL) || (data == NULL) ||
|
||||
(len == 0) || (len > ssh_string_len(s))) {
|
||||
int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len)
|
||||
{
|
||||
if ((s == NULL) || (data == NULL) || (len == 0) ||
|
||||
(len > ssh_string_len(s))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -105,7 +106,8 @@ int ssh_string_fill(struct ssh_string_struct *s, const void *data, size_t len) {
|
||||
*
|
||||
* @note The null byte is not copied nor counted in the output string.
|
||||
*/
|
||||
struct ssh_string_struct *ssh_string_from_char(const char *what) {
|
||||
struct ssh_string_struct *ssh_string_from_char(const char *what)
|
||||
{
|
||||
struct ssh_string_struct *ptr;
|
||||
size_t len;
|
||||
|
||||
@@ -133,7 +135,8 @@ struct ssh_string_struct *ssh_string_from_char(const char *what) {
|
||||
*
|
||||
* @return The size of the content of the string, 0 on error.
|
||||
*/
|
||||
size_t ssh_string_len(struct ssh_string_struct *s) {
|
||||
size_t ssh_string_len(struct ssh_string_struct *s)
|
||||
{
|
||||
size_t size;
|
||||
|
||||
if (s == NULL) {
|
||||
@@ -178,7 +181,8 @@ const char *ssh_string_get_char(struct ssh_string_struct *s)
|
||||
* @note If the input SSH string contains zeroes, some parts of the output
|
||||
* string may not be readable with regular libc functions.
|
||||
*/
|
||||
char *ssh_string_to_char(struct ssh_string_struct *s) {
|
||||
char *ssh_string_to_char(struct ssh_string_struct *s)
|
||||
{
|
||||
size_t len;
|
||||
char *new;
|
||||
|
||||
@@ -206,7 +210,8 @@ char *ssh_string_to_char(struct ssh_string_struct *s) {
|
||||
*
|
||||
* @param[in] s The string to delete.
|
||||
*/
|
||||
void ssh_string_free_char(char *s) {
|
||||
void ssh_string_free_char(char *s)
|
||||
{
|
||||
SAFE_FREE(s);
|
||||
}
|
||||
|
||||
@@ -218,7 +223,8 @@ void ssh_string_free_char(char *s) {
|
||||
*
|
||||
* @return Newly allocated copy of the string, NULL on error.
|
||||
*/
|
||||
struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s) {
|
||||
struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s)
|
||||
{
|
||||
struct ssh_string_struct *new;
|
||||
size_t len;
|
||||
|
||||
@@ -246,7 +252,8 @@ struct ssh_string_struct *ssh_string_copy(struct ssh_string_struct *s) {
|
||||
*
|
||||
* @param[in] s The string to burn.
|
||||
*/
|
||||
void ssh_string_burn(struct ssh_string_struct *s) {
|
||||
void ssh_string_burn(struct ssh_string_struct *s)
|
||||
{
|
||||
if (s == NULL || s->size == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -261,7 +268,8 @@ void ssh_string_burn(struct ssh_string_struct *s) {
|
||||
*
|
||||
* @return Return the data of the string or NULL on error.
|
||||
*/
|
||||
void *ssh_string_data(struct ssh_string_struct *s) {
|
||||
void *ssh_string_data(struct ssh_string_struct *s)
|
||||
{
|
||||
if (s == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -274,7 +282,8 @@ void *ssh_string_data(struct ssh_string_struct *s) {
|
||||
*
|
||||
* \param[in] s The SSH string to delete.
|
||||
*/
|
||||
void ssh_string_free(struct ssh_string_struct *s) {
|
||||
void ssh_string_free(struct ssh_string_struct *s)
|
||||
{
|
||||
SAFE_FREE(s);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user