Skip to content

Commit

Permalink
lib/cds: removed trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Nov 13, 2023
1 parent 6ffa465 commit 1cff98a
Show file tree
Hide file tree
Showing 32 changed files with 213 additions and 213 deletions.
2 changes: 1 addition & 1 deletion src/lib/cds/base64.c
Expand Up @@ -89,7 +89,7 @@ void base64encode(char* src_buf, int src_len, char* tgt_buf, int* tgt_len, int q
(*tgt_len)--;
else
/* this data is going to be quoted */
tgt_buf[*tgt_len+2] = '=';
tgt_buf[*tgt_len+2] = '=';
}
if (pos+2 < src_len)
tgt_buf[*tgt_len+3] = code64[(unsigned char)src_buf[pos+2] & 0x3F];
Expand Down
12 changes: 6 additions & 6 deletions src/lib/cds/cds.c
Expand Up @@ -14,12 +14,12 @@ static init_data_t *init = NULL;
/* these functions are internal and thus are not presented in headers !*/
int reference_counter_initialize();
void reference_counter_cleanup();

int cds_initialize()
{
int res = 0;

/* initialization should be called from one process/thread
/* initialization should be called from one process/thread
* it is not synchronized because it is impossible ! */
if (!init) {
init = (init_data_t*)cds_malloc(sizeof(init_data_t));
Expand All @@ -33,11 +33,11 @@ int cds_initialize()
}
else {
DEBUG_LOG("init the content\n");

/* !!! put the real initialization here !!! */
res = reference_counter_initialize();
}

if (res == 0) init->init_cnt++;
return res;
}
Expand All @@ -47,10 +47,10 @@ void cds_cleanup()
if (init) {
if (--init->init_cnt == 0) {
DEBUG_LOG("cleaning the content\n");

/* !!! put the real destruction here !!! */
reference_counter_cleanup();

cds_free(init);
init = NULL;
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib/cds/cds.h
@@ -1,7 +1,7 @@
#ifndef __CDS_H
#define __CDS_H

/** \defgroup cds CDS library - Common Data Structures
/** \defgroup cds CDS library - Common Data Structures
*
* This library contains many useful functions and data structures. It is
possible to use it with Sip Express Router (SER) or without it. In the first
Expand All @@ -21,7 +21,7 @@
* \section cds_ser_usage Usage with SER
* There can be problems with using shared libraries on different platforms.
* Currently supported solution is that user must supply LD_LIBRARY_PATH
* (or something similar on his OS) with the path to the library before
* (or something similar on his OS) with the path to the library before
* starting SER with modules needed the library.
*
* \section cds_nonser_usage Usage without SER
Expand All @@ -35,7 +35,7 @@
* There were following reasons to introduce this library:
* - many duplicated functions in modules (copy&pasted between modules)
* without touching SER's core
* - possibility to debug programs outside of SER due to its simplicity
* - possibility to debug programs outside of SER due to its simplicity
* and many useful tools
*
* @{ */
Expand All @@ -49,14 +49,14 @@ extern "C" {

/** \defgroup cds_init Initialization/destruction
* Library needs to be initialized before using it and
* un-initialized after it is not used more. Use \ref cds_initialize and
* un-initialized after it is not used more. Use \ref cds_initialize and
* \ref cds_cleanup for this purpose.
* @{ */

/** Initializes CDS library.
/** Initializes CDS library.
*
* Currently initializes reference counter which is experimental and
* probably will be removed in the future because seems to be rather
* Currently initializes reference counter which is experimental and
* probably will be removed in the future because seems to be rather
* useless here. */
int cds_initialize();

Expand Down
6 changes: 3 additions & 3 deletions src/lib/cds/dbid.c
Expand Up @@ -10,7 +10,7 @@ void generate_dbid_ptr(dbid_t dst, void *data_ptr)
{
/* TODO: add cluster distinctive member */
/* FIXME: replace sprintf by something more effective */
snprintf(dst, MAX_DBID_LEN, "%px%xx%x",
snprintf(dst, MAX_DBID_LEN, "%px%xx%x",
data_ptr, (int)time(NULL), rand());
}

Expand All @@ -21,14 +21,14 @@ void generate_dbid(dbid_t dst)
{
static int cntr = 0;
static pid_t my_pid = -1;

if (my_pid < 0) {
my_pid = getpid();
}

/* TODO: add cluster distinctive member */
/* FIXME: replace sprintf by something more effective */
snprintf(dst, MAX_DBID_LEN, "%xy%xy%xy%x",
snprintf(dst, MAX_DBID_LEN, "%xy%xy%xy%x",
my_pid, cntr++, (int)time(NULL), rand());
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/cds/dbid.h
Expand Up @@ -21,7 +21,7 @@ void generate_dbid(dbid_t dst);
#endif

/* macros for conversion to string representation of DBID
* (if dbid becomes structure with binary information
* (if dbid becomes structure with binary information
* these should be removed and replaced by functions) */
#define dbid_strlen(id) strlen(id)
#define dbid_strptr(id) ((char*)(id))
Expand Down
20 changes: 10 additions & 10 deletions src/lib/cds/dstring.c
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down Expand Up @@ -32,10 +32,10 @@

#define get_current_buffer(dstr) (dstr)->last

static dstr_buff_t *add_new_buffer(dstring_t *dstr)
static dstr_buff_t *add_new_buffer(dstring_t *dstr)
{
dstr_buff_t *buff = NULL;

/* e = dlink_element_alloc_pkg(sizeof(dstr_buff_t) + dstr->buff_size); */
/* if (dstr->flags & DSTR_PKG_MEM)
buff = cds_malloc_pkg(sizeof(dstr_buff_t) + dstr->buff_size);
Expand Down Expand Up @@ -63,7 +63,7 @@ int dstr_append(dstring_t *dstr, const char *s, int len)
if (dstr->error) return -2;

if (len == 0) return 0; /*append empty string*/

buff = get_current_buffer(dstr);
if (!buff) buff = add_new_buffer(dstr);
while ((len > 0) && (buff)) {
Expand Down Expand Up @@ -106,10 +106,10 @@ int dstr_append_str(dstring_t *dstr, const str_t *s)
int dstr_get_data(dstring_t *dstr, char *dst)
{
dstr_buff_t* buff;

/* if (!dstr) return -1; */
if (dstr->error) return -2; /* a previous operation returned error */

buff = dstr->first;
while (buff) {
memcpy(dst, buff->data, buff->used);
Expand All @@ -122,7 +122,7 @@ int dstr_get_data(dstring_t *dstr, char *dst)
int dstr_get_str(dstring_t *dstr, str_t *dst)
{
int res = 0;

if (!dst) return -1;
if (dstr->error) {
dst->s = NULL;
Expand All @@ -138,7 +138,7 @@ int dstr_get_str(dstring_t *dstr, str_t *dst)
dst->len = 0;
}
else res = dstr_get_data(dstr, dst->s);
}
}
else {
dst->s = NULL;
dst->len = 0;
Expand All @@ -150,7 +150,7 @@ int dstr_get_str(dstring_t *dstr, str_t *dst)
int dstr_get_str_pkg(dstring_t *dstr, str_t *dst)
{
int res = 0;

if (!dst) return -1;
if (dstr->error) {
dst->s = NULL;
Expand All @@ -166,7 +166,7 @@ int dstr_get_str_pkg(dstring_t *dstr, str_t *dst)
dst->len = 0;
}
else res = dstr_get_data(dstr, dst->s);
}
}
else {
dst->s = NULL;
dst->len = 0;
Expand Down
18 changes: 9 additions & 9 deletions src/lib/cds/dstring.h
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down Expand Up @@ -39,20 +39,20 @@ extern "C" {
* Dynamic strings were introduced to satisfy needs of presence
* modules when building presence documents.
*
* Dynamic string uses a list of buffers holding data.
* Dynamic string uses a list of buffers holding data.
* Buffers are allocated when needed - when there is not enough
* space in the last buffer. The whole result can be copied into one
* destination buffer with \ref dstr_get_data, \ref dstr_get_str
* or \ref dstr_get_str_pkg function.
*
* \todo Function with sprintf syntax which will help with
* \todo Function with sprintf syntax which will help with
* readibility of code using dynamic strings.
* @{
* */

/** Buffer used by dynamic string.
/** Buffer used by dynamic string.
*
* \todo 'len' and 'used' can be replaced by 'unused' member
* \todo 'len' and 'used' can be replaced by 'unused' member
* but it doesn't save too much */
typedef struct _dstr_buff_t {
int len; /**< the buffer length */
Expand Down Expand Up @@ -100,13 +100,13 @@ int dstr_append_str(dstring_t *dstr, const str_t *s);
/* int dstr_get_data_length(dstring_t *dstr); */

/** Returns data stored in dynamic string. It does NOT allocate
* space for them - it expects that the buffer is already allocated.
* space for them - it expects that the buffer is already allocated.
* \retval 0 if successful
* \retval negative on error */
int dstr_get_data(dstring_t *dstr, char *dst);

/** Returns data stored in dynamic string. It allocates space for
* them with cds_malloc (SER's shared memory).
* them with cds_malloc (SER's shared memory).
* \retval 0 if successful
* \retval negative on error */
int dstr_get_str(dstring_t *dstr, str_t *dst);
Expand All @@ -118,7 +118,7 @@ int dstr_get_str(dstring_t *dstr, str_t *dst);
int dstr_get_str_pkg(dstring_t *dstr, str_t *dst);
/** Initializes dynamic string.
* \param dstr dynamic string to be initialized
* \param buff_size size of buffer used with this dynamic string
* \param buff_size size of buffer used with this dynamic string
* \retval 0 if successful
* \retval negative on error */
int dstr_init(dstring_t *dstr, int buff_size);
Expand Down Expand Up @@ -146,5 +146,5 @@ void dstr_clear_error(dstring_t *dstr); */
#ifdef __cplusplus
}
#endif

#endif
22 changes: 11 additions & 11 deletions src/lib/cds/hash_table.c
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down Expand Up @@ -53,7 +53,7 @@ void ht_destroy(hash_table_t *ht)
{
ht_element_t *e, *n;
int i;

if (!ht) return;
if (ht->cslots) {
for (i = 0; i < ht->size; i++) {
Expand All @@ -73,17 +73,17 @@ int ht_add(hash_table_t *ht, ht_key_t key, ht_data_t data)
{
int h;
ht_element_t *new_e;

if (!ht) return -1;
new_e = (ht_element_t*)cds_malloc(sizeof(ht_element_t));
if (!new_e) return -1;
new_e->next = NULL;
new_e->key = key;
new_e->data = data;

h = ht->hash(key) % ht->size;
if (h < 0) h = -h;

if (!ht->cslots[h].last) {
ht->cslots[h].first = new_e;
}
Expand All @@ -102,9 +102,9 @@ ht_data_t ht_find(hash_table_t *ht, ht_key_t key)
ht_element_t *e;

if (!ht) return NULL;

ht->find_cnt++; //monitor

h = ht->hash(key) % ht->size;
if (h < 0) h = -h;
e = ht->cslots[h].first;
Expand All @@ -114,7 +114,7 @@ ht_data_t ht_find(hash_table_t *ht, ht_key_t key)
if (ht->cmp(e->key, key) == 0) return e->data;
e = e->next;
}

ht->missed_cnt++; //monitor
return NULL;
}
Expand All @@ -124,7 +124,7 @@ ht_data_t ht_remove(hash_table_t *ht, ht_key_t key)
int h;
ht_element_t *e,*p;
ht_data_t data;

if (!ht) return NULL;
h = ht->hash(key) % ht->size;
if (h < 0) h = -h;
Expand Down Expand Up @@ -166,7 +166,7 @@ void ht_get_statistic(hash_table_t *ht, ht_statistic_t *s)
void ht_clear_statistic(hash_table_t *ht)
{
if (!ht) return;

ht->find_cnt = 0;
ht->cmp_cnt = 0;
ht->nocmp_cnt = 0;
Expand Down Expand Up @@ -197,7 +197,7 @@ ht_element_t *get_next_ht_element(ht_traversal_info_t *info)
if (!info) return NULL;

if (info->current) info->current = info->current->next;

if (info->current) return info->current;
else {
for (i = info->slot_pos + 1; i < info->ht->size; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cds/hash_table.h
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cds/list.h
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cds/logger.h
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cds/memory.c
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2005 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
Expand Down

0 comments on commit 1cff98a

Please sign in to comment.