* init a list */
| 84 | * init a list |
| 85 | */ |
| 86 | msg_list msg_list_init(void) |
| 87 | { |
| 88 | msg_list ml = NULL; |
| 89 | |
| 90 | ml = (msg_list)shm_malloc(sizeof(t_msg_list)); |
| 91 | if(ml == NULL) |
| 92 | return NULL; |
| 93 | /* init locks */ |
| 94 | if (lock_init(&ml->sem_sent)==0){ |
| 95 | LM_CRIT("could not initialize a lock\n"); |
| 96 | goto clean; |
| 97 | }; |
| 98 | if (lock_init(&ml->sem_done)==0){ |
| 99 | LM_CRIT("could not initialize a lock\n"); |
| 100 | lock_destroy(&ml->sem_sent); |
| 101 | goto clean; |
| 102 | }; |
| 103 | ml->nrsent = 0; |
| 104 | ml->nrdone = 0; |
| 105 | ml->lsent = NULL; |
| 106 | ml->ldone = NULL; |
| 107 | |
| 108 | return ml; |
| 109 | |
| 110 | clean: |
| 111 | shm_free(ml); |
| 112 | return NULL; |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * free a list |
no test coverage detected