Skip to content

Commit

Permalink
ims_usrloc_pcscf: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent a840365 commit 8598f4e
Show file tree
Hide file tree
Showing 18 changed files with 2,278 additions and 1,989 deletions.
253 changes: 138 additions & 115 deletions src/modules/ims_usrloc_pcscf/dlist.c

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions src/modules/ims_usrloc_pcscf/dlist.h
Expand Up @@ -54,24 +54,25 @@
/*!
* List of all domains registered with usrloc
*/
typedef struct dlist {
str name; /*!< Name of the domain (null terminated) */
udomain_t* d; /*!< Payload */
struct dlist* next; /*!< Next element in the list */
typedef struct dlist
{
str name; /*!< Name of the domain (null terminated) */
udomain_t *d; /*!< Payload */
struct dlist *next; /*!< Next element in the list */
} dlist_t;

/*! \brief Global list of all registered domains */
extern dlist_t* root;
extern dlist_t *root;

int register_udomain(const char* _n, udomain_t** _d);
int register_udomain(const char *_n, udomain_t **_d);
void free_all_udomains(void);
void print_all_udomains(FILE* _f);
void print_all_udomains(FILE *_f);
int synchronize_all_udomains(void);
int get_all_ucontacts(void *buf, int len, unsigned int flags,
unsigned int part_idx, unsigned int part_max);
int get_udomain(const char* _n, udomain_t** _d);
int get_udomain(const char *_n, udomain_t **_d);
unsigned long get_number_of_users(void);
int find_domain(str* _d, udomain_t** _p);
int find_domain(str *_d, udomain_t **_p);

/* stat retrieval functions */
unsigned long get_number_of_contacts(void);
Expand Down
53 changes: 25 additions & 28 deletions src/modules/ims_usrloc_pcscf/hslot.c
Expand Up @@ -46,45 +46,42 @@
#include "hslot.h"

/*! number of locks */
int ul_locks_no=4;
int ul_locks_no = 4;
/*! global list of locks */
gen_lock_set_t* ul_locks=0;
gen_lock_set_t *ul_locks = 0;

int ul_init_locks(void)
{
int i;
i = ul_locks_no;
do {
if ((( ul_locks=lock_set_alloc(i))!=0)&&
(lock_set_init(ul_locks)!=0))
{
if(((ul_locks = lock_set_alloc(i)) != 0)
&& (lock_set_init(ul_locks) != 0)) {
ul_locks_no = i;
LM_INFO("locks array size %d\n", ul_locks_no);
return 0;

}
if (ul_locks){
if(ul_locks) {
lock_set_dealloc(ul_locks);
ul_locks=0;
ul_locks = 0;
}
i--;
if(i==0)
{
if(i == 0) {
LM_ERR("failed to allocate locks\n");
return -1;
}
} while (1);
} while(1);
}


void ul_unlock_locks(void)
{
unsigned int i;

if (ul_locks==0)
if(ul_locks == 0)
return;

for (i=0;i<ul_locks_no;i++) {
for(i = 0; i < ul_locks_no; i++) {
#ifdef GEN_LOCK_T_PREFERED
lock_release(&ul_locks->locks[i]);
#else
Expand All @@ -95,7 +92,7 @@ void ul_unlock_locks(void)

void ul_destroy_locks(void)
{
if (ul_locks !=0){
if(ul_locks != 0) {
lock_set_destroy(ul_locks);
lock_set_dealloc(ul_locks);
};
Expand All @@ -114,39 +111,39 @@ void ul_release_idx(int idx)
}
#endif

void init_slot(struct udomain* _d, hslot_t* _s, int n)
void init_slot(struct udomain *_d, hslot_t *_s, int n)
{
_s->n = 0;
_s->first = 0;
_s->last = 0;
_s->d = _d;

#ifdef GEN_LOCK_T_PREFERED
_s->lock = &ul_locks->locks[n%ul_locks_no];
_s->lock = &ul_locks->locks[n % ul_locks_no];
#else
_s->lockidx = n%ul_locks_no;
_s->lockidx = n % ul_locks_no;
#endif
}

void deinit_slot(hslot_t* _s)
void deinit_slot(hslot_t *_s)
{
struct pcontact* ptr;
/* Remove all elements */
struct pcontact *ptr;

/* Remove all elements */
while(_s->first) {
ptr = _s->first;
_s->first = _s->first->next;
free_pcontact(ptr);
}

_s->n = 0;
_s->last = 0;
_s->d = 0;
_s->d = 0;
}

void slot_add(hslot_t* _s, struct pcontact* _r)
void slot_add(hslot_t *_s, struct pcontact *_r)
{
if (_s->n == 0) {
if(_s->n == 0) {
_s->first = _s->last = _r;
} else {
_r->prev = _s->last;
Expand All @@ -157,15 +154,15 @@ void slot_add(hslot_t* _s, struct pcontact* _r)
_r->slot = _s;
}

void slot_rem(hslot_t* _s, struct pcontact* _r)
void slot_rem(hslot_t *_s, struct pcontact *_r)
{
if (_r->prev) {
if(_r->prev) {
_r->prev->next = _r->next;
} else {
_s->first = _r->next;
}

if (_r->next) {
if(_r->next) {
_r->next->prev = _r->prev;
} else {
_s->last = _r->prev;
Expand Down
23 changes: 12 additions & 11 deletions src/modules/ims_usrloc_pcscf/hslot.h
Expand Up @@ -56,22 +56,23 @@ struct udomain;
struct pcontact;


typedef struct hslot {
int n; /*!< Number of elements in the collision slot */
struct pcontact* first; /*!< First element in the list */
struct pcontact* last; /*!< Last element in the list */
struct udomain* d; /*!< Domain we belong to */
typedef struct hslot
{
int n; /*!< Number of elements in the collision slot */
struct pcontact *first; /*!< First element in the list */
struct pcontact *last; /*!< Last element in the list */
struct udomain *d; /*!< Domain we belong to */
#ifdef GEN_LOCK_T_PREFERED
gen_lock_t *lock; /*!< Lock for hash entry - fastlock */
gen_lock_t *lock; /*!< Lock for hash entry - fastlock */
#else
int lockidx; /*!< Lock index for hash entry - the rest*/
int lockidx; /*!< Lock index for hash entry - the rest*/
#endif
} hslot_t;

void init_slot(struct udomain* _d, hslot_t* _s, int n);
void deinit_slot(hslot_t* _s);
void slot_add(hslot_t* _s, struct pcontact* _r);
void slot_rem(hslot_t* _s, struct pcontact* _r);
void init_slot(struct udomain *_d, hslot_t *_s, int n);
void deinit_slot(hslot_t *_s);
void slot_add(hslot_t *_s, struct pcontact *_r);
void slot_rem(hslot_t *_s, struct pcontact *_r);
int ul_init_locks(void);
void ul_unlock_locks(void);
void ul_destroy_locks(void);
Expand Down

0 comments on commit 8598f4e

Please sign in to comment.