From 1cff98a0131e3f11d4c027ad9bf2073759bdd6a1 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Mon, 13 Nov 2023 15:28:10 +0100 Subject: [PATCH] lib/cds: removed trailing spaces --- src/lib/cds/base64.c | 2 +- src/lib/cds/cds.c | 12 +++++----- src/lib/cds/cds.h | 14 ++++++------ src/lib/cds/dbid.c | 6 ++--- src/lib/cds/dbid.h | 2 +- src/lib/cds/dstring.c | 20 ++++++++-------- src/lib/cds/dstring.h | 18 +++++++-------- src/lib/cds/hash_table.c | 22 +++++++++--------- src/lib/cds/hash_table.h | 2 +- src/lib/cds/list.h | 2 +- src/lib/cds/logger.h | 2 +- src/lib/cds/memory.c | 2 +- src/lib/cds/memory.h | 20 ++++++++-------- src/lib/cds/msg_queue.c | 24 ++++++++++---------- src/lib/cds/msg_queue.h | 24 ++++++++++---------- src/lib/cds/ptr_vector.c | 2 +- src/lib/cds/ptr_vector.h | 2 +- src/lib/cds/ref_cntr.h | 44 ++++++++++++++++++------------------ src/lib/cds/rr_serialize.c | 26 ++++++++++----------- src/lib/cds/ser_profile.c | 36 ++++++++++++++--------------- src/lib/cds/ser_profile.h | 2 +- src/lib/cds/serialize.c | 42 +++++++++++++++++----------------- src/lib/cds/serialize.h | 2 +- src/lib/cds/simple_profile.c | 6 ++--- src/lib/cds/simple_profile.h | 4 ++-- src/lib/cds/sip_utils.c | 10 ++++---- src/lib/cds/sip_utils.h | 6 ++--- src/lib/cds/sstr.c | 40 ++++++++++++++++---------------- src/lib/cds/sstr.h | 8 +++---- src/lib/cds/sync.h | 2 +- src/lib/cds/vector.c | 18 +++++++-------- src/lib/cds/vector.h | 4 ++-- 32 files changed, 213 insertions(+), 213 deletions(-) diff --git a/src/lib/cds/base64.c b/src/lib/cds/base64.c index d2d379934e2..60e6b2b5e80 100644 --- a/src/lib/cds/base64.c +++ b/src/lib/cds/base64.c @@ -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]; diff --git a/src/lib/cds/cds.c b/src/lib/cds/cds.c index 0079fd13f9d..75a13d1f78a 100644 --- a/src/lib/cds/cds.c +++ b/src/lib/cds/cds.c @@ -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)); @@ -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; } @@ -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; } diff --git a/src/lib/cds/cds.h b/src/lib/cds/cds.h index d72e191b2a1..5d5e222afe9 100644 --- a/src/lib/cds/cds.h +++ b/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 @@ -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 @@ -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 * * @{ */ @@ -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(); diff --git a/src/lib/cds/dbid.c b/src/lib/cds/dbid.c index 64959195f81..96f907bc9f5 100644 --- a/src/lib/cds/dbid.c +++ b/src/lib/cds/dbid.c @@ -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()); } @@ -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()); } diff --git a/src/lib/cds/dbid.h b/src/lib/cds/dbid.h index 5f86bbbcd9c..0844ec63b23 100644 --- a/src/lib/cds/dbid.h +++ b/src/lib/cds/dbid.h @@ -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)) diff --git a/src/lib/cds/dstring.c b/src/lib/cds/dstring.c index 61d566c6381..9be2bf9bc86 100644 --- a/src/lib/cds/dstring.c +++ b/src/lib/cds/dstring.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -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); @@ -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)) { @@ -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); @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/src/lib/cds/dstring.h b/src/lib/cds/dstring.h index dcafb16d0f1..f54acf7d46e 100644 --- a/src/lib/cds/dstring.h +++ b/src/lib/cds/dstring.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -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 */ @@ -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); @@ -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); @@ -146,5 +146,5 @@ void dstr_clear_error(dstring_t *dstr); */ #ifdef __cplusplus } #endif - + #endif diff --git a/src/lib/cds/hash_table.c b/src/lib/cds/hash_table.c index 198dac57d41..e3cb326d9b0 100644 --- a/src/lib/cds/hash_table.c +++ b/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. @@ -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++) { @@ -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; } @@ -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; @@ -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; } @@ -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; @@ -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; @@ -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++) { diff --git a/src/lib/cds/hash_table.h b/src/lib/cds/hash_table.h index 0692c0e6b65..818af9a2c0f 100644 --- a/src/lib/cds/hash_table.h +++ b/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. diff --git a/src/lib/cds/list.h b/src/lib/cds/list.h index 87cd5d1b8ab..9833e471137 100644 --- a/src/lib/cds/list.h +++ b/src/lib/cds/list.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/logger.h b/src/lib/cds/logger.h index e17eb632f65..6a4f3bb464e 100644 --- a/src/lib/cds/logger.h +++ b/src/lib/cds/logger.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/memory.c b/src/lib/cds/memory.c index a64a55e0367..32cc4b317d1 100644 --- a/src/lib/cds/memory.c +++ b/src/lib/cds/memory.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/memory.h b/src/lib/cds/memory.h index 1429745b5d8..b4a25750b2c 100644 --- a/src/lib/cds/memory.h +++ b/src/lib/cds/memory.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -33,14 +33,14 @@ extern "C" { #endif /** \ingroup cds - * @{ + * @{ * * \defgroup cds_memory Memory management * * Memory operations are common for whole CDS library. Because it must work together with SER's memory management and must work without it too, there are wrapper macros for memory allocation/deallocation. - * + * * @{ */ /* typedef void*(*cds_malloc_func)(unsigned int size); @@ -53,37 +53,37 @@ void cds_set_memory_functions(cds_malloc_func _malloc, cds_free_func _free); */ /** \def cds_malloc(s) * Function/macro for memory allocation. Which function is choosen depends on - * SER and TRACE_CDS_MEMORY defines. + * SER and TRACE_CDS_MEMORY defines. * * When SER is defined shm_malloc is choosen, standard malloc otherwise. */ /** \def cds_free(p) * Function/macro for memory deallocation. Which function is choosen depends - * on SER and TRACE_CDS_MEMORY defines. + * on SER and TRACE_CDS_MEMORY defines. * * If SER is defined shm_free is choosen, standard free otherwise. */ /** \def cds_malloc_ptr * Function/macro for memory allocation when pointer to function needed. Which - * function is choosen depends on SER and TRACE_CDS_MEMORY defines. + * function is choosen depends on SER and TRACE_CDS_MEMORY defines. * * If SER is defined shm_malloc is choosen, standard malloc otherwise. */ /** \def cds_free_ptr * Function/macro for memory deallocation when pointer to function needed. - * Which function is choosen depends on SER and TRACE_CDS_MEMORY defines. + * Which function is choosen depends on SER and TRACE_CDS_MEMORY defines. * * If SER is defined shm_free is choosen, standard free otherwise. */ /** \def cds_malloc_pkg(s) * Function/macro for 'local' memory allocation. Which function is choosen - * depends on SER and TRACE_CDS_MEMORY defines. + * depends on SER and TRACE_CDS_MEMORY defines. * * When SER is defined pkg_malloc is choosen, standard malloc otherwise. */ /** \def cds_free_pkg(p) * Function/macro for 'local' memory deallocation. Which function is choosen - * depends on SER and TRACE_CDS_MEMORY defines. + * depends on SER and TRACE_CDS_MEMORY defines. * * When SER is defined pkg_free is choosen, standard free otherwise. */ @@ -154,7 +154,7 @@ void shm_free_x(void *ptr); } #endif -/** @} +/** @} * @} */ #endif diff --git a/src/lib/cds/msg_queue.c b/src/lib/cds/msg_queue.c index ec63cc3c547..ca4d1fd1ebc 100644 --- a/src/lib/cds/msg_queue.c +++ b/src/lib/cds/msg_queue.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -61,7 +61,7 @@ void init_message_ex(mq_message_t *m, void *data, int data_len, destroy_function { /* if (data_len < 0) data_len = 0; */ if (!m) return; - + m->data_len = data_len; m->data = data; m->next = NULL; @@ -76,12 +76,12 @@ void set_data_destroy_function(mq_message_t *msg, destroy_function_f func) void free_message(mq_message_t *msg) { - if (msg->destroy_function && msg->data) + if (msg->destroy_function && msg->data) msg->destroy_function(msg->data); switch (msg->allocation_style) { - case message_allocated_with_data: + case message_allocated_with_data: break; - case message_holding_data_ptr: + case message_holding_data_ptr: /* if (msg->data) cds_free(msg->data); */ break; } @@ -92,7 +92,7 @@ int push_message(msg_queue_t *q, mq_message_t *m) { if ((!q) || (!m)) return -1; m->next = NULL; - + if (q->flags & MQ_USE_MUTEX) cds_mutex_lock(&q->q_mutex); if (q->last) q->last->next = m; else { @@ -101,7 +101,7 @@ int push_message(msg_queue_t *q, mq_message_t *m) } q->last = m; if (q->flags & MQ_USE_MUTEX) cds_mutex_unlock(&q->q_mutex); - + return 0; } @@ -109,13 +109,13 @@ int mq_add_to_top(msg_queue_t *q, mq_message_t *m) { if ((!q) || (!m)) return -1; m->next = NULL; - + if (q->flags & MQ_USE_MUTEX) cds_mutex_lock(&q->q_mutex); m->next = q->first; q->first = m; if (!q->last) q->last = m; if (q->flags & MQ_USE_MUTEX) cds_mutex_unlock(&q->q_mutex); - + return 0; } @@ -135,7 +135,7 @@ mq_message_t *pop_message(msg_queue_t *q) m->next = NULL; } if (q->flags & MQ_USE_MUTEX) cds_mutex_unlock(&q->q_mutex); - + return m; } @@ -165,13 +165,13 @@ int msg_queue_init_ex(msg_queue_t *q, int synchronize) return 0; } -/** \internal Destroys all internal data of message queue and +/** \internal Destroys all internal data of message queue and * optionally frees it if no more references exist. */ static inline void msg_queue_destroy_and_free(msg_queue_t *q, int do_free) { mq_message_t *m,*n; if (!q) return; - + if (q->flags & MQ_USE_REF_CNTR) { if (!remove_reference(&q->ref)) { /* this was NOT the last reference */ diff --git a/src/lib/cds/msg_queue.h b/src/lib/cds/msg_queue.h index 7f2569e8e61..22d15cc7d24 100644 --- a/src/lib/cds/msg_queue.h +++ b/src/lib/cds/msg_queue.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -33,8 +33,8 @@ extern "C" { #endif -/** - * \ingroup cds +/** + * \ingroup cds * \defgroup cds_msg_queue Message Queue * * Message queue is a structure useful for sending data between processes. @@ -71,7 +71,7 @@ typedef struct _mq_message_t { struct _mq_message_t *next; /** pointer to destroy function */ destroy_function_f destroy_function; - enum { + enum { message_allocated_with_data, /**< data are allocated together with message structure */ message_holding_data_ptr /**< message holds only pointer to data */ } allocation_style; /**< member describing the manner of data storage */ @@ -84,12 +84,12 @@ typedef struct _mq_message_t { * msg_queue_init or \ref msg_queue_init_ex. */ #define MQ_USE_MUTEX 1 -/** Message queue flag meaning that reference counters are used. +/** Message queue flag meaning that reference counters are used. * To set this flag is needed to call \ref msg_queue_init_ref_cnt with - * non-NULL group parameter. */ + * non-NULL group parameter. */ #define MQ_USE_REF_CNTR 2 -/** Message queue structure. +/** Message queue structure. * Never access its members directly (they may change), always * use interface functions! */ @@ -112,11 +112,11 @@ typedef struct msg_queue { unsigned int flags; } msg_queue_t; -/** Macro for accessing message data. +/** Macro for accessing message data. * It is better to use this macro than accessing internal members of * the structure. */ #define get_message_data(msg) (msg ? msg->data: NULL) -/** Macro for determining message data length. +/** Macro for determining message data length. * It is better to use this macro than accessing internal members of * the structure. */ #define get_message_data_len(msg) (msg ? msg->data_len: 0) @@ -132,7 +132,7 @@ mq_message_t *create_message_ex(int data_len); * because they are automatically freed by free_message! */ mq_message_t *create_message(void *data, int data_len); -/** Sets function which will be called by free_message to destroy data. +/** Sets function which will be called by free_message to destroy data. * * This function may be useful when a complex structure with pointers is added * as data parameter. */ @@ -167,11 +167,11 @@ int msg_queue_init_ex(msg_queue_t *q, int synchronize); /** Initializes reference counter for given message queue * \param grp specifies group of reference counters to use. The message - * queue will stop using the reference counter if NULL. + * queue will stop using the reference counter if NULL. * \param q specifies the message queue */ void msg_queue_init_ref_cnt(msg_queue_t *q, reference_counter_group_t *grp); -/** Destroys message queue if no more references exist. +/** Destroys message queue if no more references exist. * This function destroys all message queue internal data but doesn't free * the message queue itself. It can be useful for statically allocated queues * or when allocated not using cds_malloc. */ diff --git a/src/lib/cds/ptr_vector.c b/src/lib/cds/ptr_vector.c index 18194a8d8af..35b15889588 100644 --- a/src/lib/cds/ptr_vector.c +++ b/src/lib/cds/ptr_vector.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/ptr_vector.h b/src/lib/cds/ptr_vector.h index 2e6deec50a6..0dbca1ce45e 100644 --- a/src/lib/cds/ptr_vector.h +++ b/src/lib/cds/ptr_vector.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/ref_cntr.h b/src/lib/cds/ref_cntr.h index e217ce1d0ba..b9a14aad2a6 100644 --- a/src/lib/cds/ref_cntr.h +++ b/src/lib/cds/ref_cntr.h @@ -6,13 +6,13 @@ extern "C" { #endif /** \ingroup cds - * @{ + * @{ * * \defgroup cds_ref_cnt Reference counting * * Experimental functions for reference counting (to simplify * this code elsewhere). - * + * * Reference counter (\ref reference_counter_data_t) holds integer number which * should be changed using functions \ref add_reference and \ref * remove_reference. Using these functions is the number read/changed from @@ -20,7 +20,7 @@ extern "C" { * * Often used scenario: * - list of structures, change in the list (adding, removing) is guarded by - * one mutex, + * one mutex, * - each structure has reference counter, when the count is zero, the * structure can be removed from the list and freed * @@ -36,7 +36,7 @@ extern "C" { * }; * * reference_counter_group_t *some_grp; - * + * * void init() * { * some_grp = init_reference_counter_group(16); @@ -46,7 +46,7 @@ extern "C" { * { * free_reference_counter_group(some_grp); * } - * + * * ... * * // adding a member: @@ -71,17 +71,17 @@ extern "C" { * free(ss); * unlock(list); * } - * - * // or - * // releasing a member when not needed for caller and it is possible - * // to 'search' in the list (reference to released member can be somehow + * + * // or + * // releasing a member when not needed for caller and it is possible + * // to 'search' in the list (reference to released member can be somehow * // obtained by inspecting the list): * lock(list); * if (remove_reference(&ss->ref)) { * // last reference removed * remove_from_list(ss); * free(ss); - * } + * } * unlock(list); * \endcode * @@ -96,29 +96,29 @@ typedef struct { cds_mutex_t *mutex; /**< mutex assigned to this reference counter */ } reference_counter_data_t; -/** Structure holding information about group of reference counters. - * It holds array of mutexes which are assigned to single reference - * counters in this group. The assignment is done using an operation +/** Structure holding information about group of reference counters. + * It holds array of mutexes which are assigned to single reference + * counters in this group. The assignment is done using an operation * on pointer to reference_counter_data_t. */ typedef struct { int mutex_cnt; /**< number of mutexes for this group */ - /** number of next mutex to be assigned - this member is NOT + /** number of next mutex to be assigned - this member is NOT * read/changed from critical section but it doesn't matter * if it will be rewritten between processes because it is used * for load distributing only (the worst thing that can happen * is that the same mutex is assigned twice) */ - int mutex_to_assign; + int mutex_to_assign; cds_mutex_t mutexes[1]; /**< array of mutexes (allocated together with the structure)*/ } reference_counter_group_t; -/** Initializes reference counter - sets its value to 1. - * After call to this function, the caller is owner of first +/** Initializes reference counter - sets its value to 1. + * After call to this function, the caller is owner of first * reference. From now it can call other functions like - * \ref add_reference or \ref remove_reference. + * \ref add_reference or \ref remove_reference. * - * This function initializes the mutex - it chooses one from - * group mutexes. The mutex can not be changed after this + * This function initializes the mutex - it chooses one from + * group mutexes. The mutex can not be changed after this * call (it is only for reading). */ void init_reference_counter(reference_counter_group_t *grp, reference_counter_data_t *ref); @@ -138,7 +138,7 @@ int get_reference_count(reference_counter_data_t *ref); * */ int remove_reference(reference_counter_data_t *ref); -/** Creates and initializes group of reference counters. All reference +/** Creates and initializes group of reference counters. All reference * counters 'belonging' to this group are using the same set of mutexes. */ reference_counter_group_t *create_reference_counter_group(int mutex_cnt); @@ -147,7 +147,7 @@ reference_counter_group_t *create_reference_counter_group(int mutex_cnt); * by this group can be used. */ void free_reference_counter_group(reference_counter_group_t *grp); -/** @} +/** @} * @} */ #ifdef __cplusplus diff --git a/src/lib/cds/rr_serialize.c b/src/lib/cds/rr_serialize.c index 252a7dc5b94..6c155f2cd74 100644 --- a/src/lib/cds/rr_serialize.c +++ b/src/lib/cds/rr_serialize.c @@ -8,9 +8,9 @@ static void rr_dup(rr_t **dst, rr_t *pkg_rr) { rr_t *tmp = NULL; int res; - + tmp = pkg_rr; - + while (pkg_rr) { res = shm_duplicate_rr(dst, pkg_rr); dst = &(*dst)->next; @@ -32,7 +32,7 @@ static int serialize_route(sstream_t *ss, rr_t **_r) else do_it = 0; if (serialize_int(ss, &do_it) != 0) return -1; } - + if (do_it) { str s; if (*_r) { @@ -43,12 +43,12 @@ static int serialize_route(sstream_t *ss, rr_t **_r) res = serialize_str_ex(ss, &s) | res; if (is_input_sstream(ss)) { rr_t *pkg_rr = NULL; - + parse_rr_body(s.s, s.len, &pkg_rr); rr_dup(_r, pkg_rr); } } - + return res; } @@ -60,12 +60,12 @@ int serialize_route_set(sstream_t *ss, rr_t **route_set) if (is_input_sstream(ss)) { /* read */ do { res = serialize_route(ss, &r) | res; - if (last) last->next = r; + if (last) last->next = r; else first = r; last = r; if (last) { /* due to parsing rr (may be more rr_t than 1) */ - while (last->next) last = last->next; + while (last->next) last = last->next; } } while (r); *route_set = first; @@ -79,7 +79,7 @@ int serialize_route_set(sstream_t *ss, rr_t **route_set) r = NULL; serialize_route(ss, &r); /* store terminating route */ } - + return 0; } @@ -87,9 +87,9 @@ int route_set2str(rr_t *rr, str_t *dst_str) { int res = 0; sstream_t store; - + init_output_sstream(&store, 256); - + if (serialize_route_set(&store, &rr) != 0) { ERROR_LOG("can't serialize route set\n"); res = -1; @@ -111,14 +111,14 @@ int str2route_set(const str_t *s, rr_t **rr) sstream_t store; if (!s) return -1; - + init_input_sstream(&store, s->s, s->len); if (serialize_route_set(&store, rr) != 0) { ERROR_LOG("can't de-serialize route set\n"); res = -1; - } + } destroy_sstream(&store); - + return res; } diff --git a/src/lib/cds/ser_profile.c b/src/lib/cds/ser_profile.c index b426ea786b5..0c7e890923b 100644 --- a/src/lib/cds/ser_profile.c +++ b/src/lib/cds/ser_profile.c @@ -12,36 +12,36 @@ DEFINE_PROF_POINT(pa_handle_subscription) DEFINE_PROF_POINT(pa_timer_presentity) DEFINE_PROF_POINT(pa_timer_pdomain) DEFINE_PROF_POINT(pa_response_generation) - + DEFINE_PROF_POINT(rls_handle_subscription) DEFINE_PROF_POINT(rls_timer_cb) DEFINE_PROF_POINT(rls_is_simple_rls_target) DEFINE_PROF_POINT(rls_query_rls_sevices) DEFINE_PROF_POINT(rls_query_resource_list) DEFINE_PROF_POINT(rls_have_flat_list) - + DEFINE_PROF_POINT(tem_timer_cb) DEFINE_PROF_POINT(tem_add_event) DEFINE_PROF_POINT(tem_remove_event) DEFINE_PROF_POINT(tem_do_step) DEFINE_PROF_POINT(b2b_handle_notify) - -void prof_trace(FILE *f, int pid, const char *s, profile_data_t a) + +void prof_trace(FILE *f, int pid, const char *s, profile_data_t a) { - fprintf(f, "%d\t%30s\t%d\t%u\n", + fprintf(f, "%d\t%30s\t%d\t%u\n", pid, s, a.count, a.spent_time); - if (a.start_count != a.stop_count) - fprintf(f, "%s, %d start_count != stop_count (%d != %d)\n", + if (a.start_count != a.stop_count) + fprintf(f, "%s, %d start_count != stop_count (%d != %d)\n", s, pid, a.start_count, a.stop_count); } -void prof_trace_nested(FILE *f, int pid, const char *s, profile_data_t a) +void prof_trace_nested(FILE *f, int pid, const char *s, profile_data_t a) { - fprintf(f, "%d\t%29s*\t%d\t%u\n", + fprintf(f, "%d\t%29s*\t%d\t%u\n", pid, s, a.count, a.spent_time); - if (a.start_count != a.stop_count) - fprintf(f, "%s, %d start_count != stop_count (%d != %d)\n", + if (a.start_count != a.stop_count) + fprintf(f, "%s, %d start_count != stop_count (%d != %d)\n", s, pid, a.start_count, a.stop_count); } @@ -56,32 +56,32 @@ void trace_func() f = fopen("/tmp/ser.profile", "at"); if (!f) ERR("can't write into profile file\n"); else { - + trace(f, p, pa_handle_subscription); trace(f, p, pa_timer_pdomain); trace_nested(f, p, pa_timer_presentity); trace_nested(f, p, pa_response_generation); - + trace(f, p, rls_handle_subscription); trace(f, p, rls_timer_cb); trace(f, p, rls_is_simple_rls_target); trace(f, p, rls_query_rls_sevices); trace(f, p, rls_query_resource_list); trace(f, p, rls_have_flat_list); - + /* trace_nested(f, p, tem_timer_cb); */ trace(f, p, tem_add_event); trace(f, p, tem_remove_event); trace(f, p, tem_do_step); - + trace(f, p, b2b_handle_notify); - + fprintf(f, "%d\t%30s\t1\t%u\n", p, "all", get_prof_time()); - + fclose(f); } } - + void ser_profile_init() { WARN("initializing profiler\n"); diff --git a/src/lib/cds/ser_profile.h b/src/lib/cds/ser_profile.h index 51aa164e8a7..0f5d55aeb1c 100644 --- a/src/lib/cds/ser_profile.h +++ b/src/lib/cds/ser_profile.h @@ -13,7 +13,7 @@ DECLARE_PROF_POINT(pa_handle_subscription) DECLARE_PROF_POINT(pa_timer_presentity) DECLARE_PROF_POINT(pa_timer_pdomain) DECLARE_PROF_POINT(pa_response_generation) - + DECLARE_PROF_POINT(rls_handle_subscription) DECLARE_PROF_POINT(rls_timer_cb) DECLARE_PROF_POINT(rls_is_simple_rls_target) diff --git a/src/lib/cds/serialize.c b/src/lib/cds/serialize.c index c4e828018aa..c715b6f939a 100644 --- a/src/lib/cds/serialize.c +++ b/src/lib/cds/serialize.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -30,7 +30,7 @@ int init_input_sstream(sstream_t *ss, char *data_in, int data_len) { if (!ss) return -1; - + ss->type = sstream_in; ss->in.len = data_len; ss->in.s = data_in; @@ -41,7 +41,7 @@ int init_input_sstream(sstream_t *ss, char *data_in, int data_len) int init_output_sstream(sstream_t *ss, int out_buff_resize) { if (!ss) return -1; - + ss->type = sstream_out; str_clear(&ss->in); ss->in_pos = 0; @@ -89,7 +89,7 @@ int sstream_get_str_ex(sstream_t *ss, int len, str_t *dst) { int l; int res = 0; - + if (!is_input_sstream(ss)) return -1; if (!dst) return -1; @@ -97,7 +97,7 @@ int sstream_get_str_ex(sstream_t *ss, int len, str_t *dst) str_clear(dst); return 0; } - + l = ss->in.len - ss->in_pos; dst->s = ss->in.s + ss->in_pos; @@ -107,7 +107,7 @@ int sstream_get_str_ex(sstream_t *ss, int len, str_t *dst) } else dst->len = len; ss->in_pos += dst->len; - + return 0; } @@ -145,26 +145,26 @@ void destroy_sstream(sstream_t *ss) int serialize_int(sstream_t *ss, int *num) { char sep = ':'; - + if (!num) return -1; - + if (is_input_sstream(ss)) { char c; int first = 1; int sign = 1; /* positive */ - + *num = 0; while (sstream_get(ss, &c) == 0) { if (c == sep) break; if ((c >= '0') && (c <= '9')) *num = 10 * (*num) + (c - '0'); else { switch (c) { - case '-': + case '-': if (first) sign = -1; else return -1; - case '+': + case '+': if (!first) return -1; - default: + default: return -1; /* unknown character */ } } @@ -184,12 +184,12 @@ int serialize_int(sstream_t *ss, int *num) int serialize_uint(sstream_t *ss, unsigned int *num) { char sep = ':'; - + if (!num) return -1; - + if (is_input_sstream(ss)) { char c; - + *num = 0; while (sstream_get(ss, &c) == 0) { if (c == sep) break; @@ -209,9 +209,9 @@ int serialize_uint(sstream_t *ss, unsigned int *num) int serialize_str(sstream_t *ss, str_t *s) { int res = 0; - - if (!s) return -1; - + + if (!s) return -1; + if (serialize_int(ss, &s->len) != 0) return -1; if (is_input_sstream(ss)) { if (s->len == 0) s->s = NULL; @@ -225,9 +225,9 @@ int serialize_str(sstream_t *ss, str_t *s) int serialize_str_ex(sstream_t *ss, str_t *s) { int res = 0; - - if (!s) return -1; - + + if (!s) return -1; + if (serialize_int(ss, &s->len) != 0) return -1; if (is_input_sstream(ss)) { if (s->len == 0) s->s = NULL; diff --git a/src/lib/cds/serialize.h b/src/lib/cds/serialize.h index 99bdb4ee2ce..923aa45fea8 100644 --- a/src/lib/cds/serialize.h +++ b/src/lib/cds/serialize.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/simple_profile.c b/src/lib/cds/simple_profile.c index 61157790d70..8cb9a635b16 100644 --- a/src/lib/cds/simple_profile.c +++ b/src/lib/cds/simple_profile.c @@ -21,9 +21,9 @@ int reset_timer() { struct itimerval tv; int res; - + tv.it_interval.tv_sec = 0; - tv.it_interval.tv_usec = 1000; + tv.it_interval.tv_usec = 1000; /*tv.it_interval.tv_usec = 10 * 1000; */ tv.it_value.tv_sec = tv.it_interval.tv_sec; tv.it_value.tv_usec = tv.it_interval.tv_usec; @@ -63,7 +63,7 @@ int start_profile(trace_f tf) /* ERROR_LOG("can't set signal handle (%d)\n", res);*/ return -1; } - + old_sigx_action = signal(trace_signal, &trace_handler); res = reset_timer(); diff --git a/src/lib/cds/simple_profile.h b/src/lib/cds/simple_profile.h index dff87c8611f..592d6b728e4 100644 --- a/src/lib/cds/simple_profile.h +++ b/src/lib/cds/simple_profile.h @@ -4,7 +4,7 @@ #ifdef __cplusplus extern "C" { #endif - + typedef void(*trace_f)(); int start_profile(trace_f tf); @@ -43,5 +43,5 @@ typedef struct { #ifdef __cplusplus } #endif - + #endif diff --git a/src/lib/cds/sip_utils.c b/src/lib/cds/sip_utils.c index b7955a14a54..716ad2e598d 100644 --- a/src/lib/cds/sip_utils.c +++ b/src/lib/cds/sip_utils.c @@ -52,19 +52,19 @@ int is_terminating_notify(struct sip_msg *m) ERR("invalid Subscription-State\n"); return 0; /* ignore */ } - + if (ss->value == ss_terminated) return 1; return 0; } -static inline int contains_extension_support(struct hdr_field *h, +static inline int contains_extension_support(struct hdr_field *h, str *extension) { /* "parses" Supported header and looks for extension */ str s, val; char *c; - + if (!h) return 0; s = h->body; @@ -99,7 +99,7 @@ int supports_extension(struct sip_msg *m, str *extension) ERR("Error while parsing headers (%d)\n", res); return 0; /* what to return here ? */ } - + h = m->supported; while (h) { if (h->type == HDR_SUPPORTED_T) { @@ -122,7 +122,7 @@ int requires_extension(struct sip_msg *m, str *extension) ERR("Error while parsing headers (%d)\n", res); return 0; /* what to return here ? */ } - + h = m->require; while (h) { if (h->type == HDR_REQUIRE_T) { diff --git a/src/lib/cds/sip_utils.h b/src/lib/cds/sip_utils.h index df086ad6ff9..c0ee6c8b338 100644 --- a/src/lib/cds/sip_utils.h +++ b/src/lib/cds/sip_utils.h @@ -5,18 +5,18 @@ #include -/* returns negative value on error, positive when message contains +/* returns negative value on error, positive when message contains * no Expires header and 0 if everything ok */ int get_expiration_value(struct sip_msg *m, int *value); /* returns 1 if the message has Subscription-Status: terminated (hack!) */ int is_terminating_notify(struct sip_msg *m); -/* returns 1 if given extension is in Supported headers, +/* returns 1 if given extension is in Supported headers, * 0 if not or an error occurred while parsing */ int supports_extension(struct sip_msg *m, str *extension); -/* returns 1 if given extension is in Require headers, +/* returns 1 if given extension is in Require headers, * 0 if not or an error occurred while parsing */ int requires_extension(struct sip_msg *m, str *extension); diff --git a/src/lib/cds/sstr.c b/src/lib/cds/sstr.c index 8ed027273ea..d57ed68e909 100644 --- a/src/lib/cds/sstr.c +++ b/src/lib/cds/sstr.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -42,12 +42,12 @@ int is_str_empty(const str_t *s) int str_cmp_zt(const str_t *a, const char *b) { int i; - + if (!a) { if (b) return 1; else return 0; } - + for (i = 0; (i < a->len) && (b[i]); i++) { if (a->s[i] < b[i]) return -1; if (a->s[i] > b[i]) return 1; @@ -160,15 +160,15 @@ char *zt_strdup(const char* src) int str_nocase_equals(const str_t *a, const str_t *b) { int i; - + if (!a) { if (!b) return 0; else return (b->len == 0) ? 0 : 1; } if (!b) return (a->len == 0) ? 0 : 1; if (a->len != b->len) return 1; - - for (i = 0; i < a->len; i++) + + for (i = 0; i < a->len; i++) if (tolower(a->s[i]) != tolower(b->s[i])) return 1; return 0; } @@ -176,15 +176,15 @@ int str_nocase_equals(const str_t *a, const str_t *b) int str_case_equals(const str_t *a, const str_t *b) { int i; - + if (!a) { if (!b) return 0; else return (b->len == 0) ? 0 : 1; } if (!b) return (a->len == 0) ? 0 : 1; if (a->len != b->len) return 1; - - for (i = 0; i < a->len; i++) + + for (i = 0; i < a->len; i++) if (a->s[i] != b->s[i]) return 1; return 0; } @@ -195,7 +195,7 @@ int str_case_equals(const str_t *a, const str_t *b) if ((s->len > 0) && (s->s)) cds_free(s->s); s->len = 0; s->s = NULL; -} +} void str_free(str_t *s) { @@ -230,7 +230,7 @@ char *str_str(const str_t *s, const str_t *search_for) if (is_str_empty(search_for)) return s->s; if (is_str_empty(s)) return NULL; - + if (search_for->len > s->len) return NULL; j = 0; @@ -254,12 +254,12 @@ int str_concat(str_t *dst, str_t *a, str_t *b) { int al; int bl; - + if (!dst) return -1; - + al = str_len(a); bl = str_len(b); - + dst->len = al + bl; if (dst->len > 0) { dst->s = (char *)cds_malloc(dst->len); @@ -273,10 +273,10 @@ int str_concat(str_t *dst, str_t *a, str_t *b) dst->len = 0; return 0; } - + if (al) memcpy(dst->s, a->s, al); if (bl) memcpy(dst->s + al, b->s, bl); - + return 0; } @@ -286,11 +286,11 @@ int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t * char *c; dstring_t str; int res, len; - + /* if (!dst) return -1; if (!src) { str_clear(dst); - return -1; + return -1; } */ if (is_str_empty(sample)) { @@ -302,7 +302,7 @@ int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t * str_clear(dst); return 0; } - + s = *src; dstr_init(&str, src->len + 32); do { @@ -317,7 +317,7 @@ int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t * } else dstr_append_str(&str, &s); } while (c); - + res = dstr_get_str(&str, dst); dstr_destroy(&str); return res; diff --git a/src/lib/cds/sstr.h b/src/lib/cds/sstr.h index 699ec094f51..745faa1cdd7 100644 --- a/src/lib/cds/sstr.h +++ b/src/lib/cds/sstr.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -35,7 +35,7 @@ extern "C" { /* If compiled for SER, use ser internal strings ! */ #ifdef SER -#include "str.h" +#include "str.h" typedef str str_t; #else @@ -49,7 +49,7 @@ typedef struct { #endif -#define FMT_STR(str) (str).len,((str).s ? (str).s : "") +#define FMT_STR(str) (str).len,((str).s ? (str).s : "") #define str_len(ptr) ((ptr)?(ptr)->len:0) @@ -123,7 +123,7 @@ int str_concat(str_t *dst, str_t *a, str_t *b); int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t *value); -/** Copies string into another one. The destination string buffer +/** Copies string into another one. The destination string buffer * MUST be allocated in needed size! */ #define str_cpy(dst, src) do { \ memcpy((dst)->s, (src)->s, (src)->len); \ diff --git a/src/lib/cds/sync.h b/src/lib/cds/sync.h index f2c771ec406..bd1cebda5dd 100644 --- a/src/lib/cds/sync.h +++ b/src/lib/cds/sync.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. diff --git a/src/lib/cds/vector.c b/src/lib/cds/vector.c index feb90edec7f..db1c850bb82 100644 --- a/src/lib/cds/vector.c +++ b/src/lib/cds/vector.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -36,21 +36,21 @@ int vector_add(vector_t *vector, void *element) void *new_data; int new_size = vector->allocated_count + vector->allocation_count; if (new_size <= vector->allocated_count) return -1; - + new_data = (void *)cds_malloc(vector->element_size * new_size); if (!new_data) return -1; if (vector->data) { - memcpy(new_data, vector->data, + memcpy(new_data, vector->data, vector->element_size * vector->allocated_count); cds_free(vector->data); } vector->data = new_data; vector->allocated_count = new_size; } - memcpy(vector->data + (vector->element_count * vector->element_size), + memcpy(vector->data + (vector->element_count * vector->element_size), element, vector->element_size); vector->element_count++; - + return 0; } @@ -58,22 +58,22 @@ int vector_remove(vector_t *vector, int index) { int cnt; if (index >= vector->element_count) return -1; - + cnt = vector->element_count - index - 1; if (cnt > 0) { - memmove(vector->data + (index * vector->element_size), + memmove(vector->data + (index * vector->element_size), vector->data + ((index + 1) * vector->element_size), cnt * vector->element_size); } vector->element_count--; - + return 0; } int vector_get(vector_t *vector, int index, void *element_dst) { if (index >= vector->element_count) return -1; - + memcpy(element_dst, vector->data + (index * vector->element_size), vector->element_size); return 0; diff --git a/src/lib/cds/vector.h b/src/lib/cds/vector.h index fa4bef7347a..c13fc217970 100644 --- a/src/lib/cds/vector.h +++ b/src/lib/cds/vector.h @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005 iptelorg GmbH * * This file is part of ser, a free SIP server. @@ -38,7 +38,7 @@ typedef struct { int element_count; /** the number of allocated elements */ int allocated_count; - /** number of elements allocated together (better than allocation + /** number of elements allocated together (better than allocation * for each element separately) */ int allocation_count; void *data;