Lines Matching refs:id_pool

20 	struct sip_svc_id_pool *id_pool = NULL;  in sip_svc_id_mgr_create()  local
29 id_pool = k_malloc(sizeof(struct sip_svc_id_pool)); in sip_svc_id_mgr_create()
30 if (!id_pool) { in sip_svc_id_mgr_create()
33 id_pool->size = size; in sip_svc_id_mgr_create()
35 id_pool->id_list = k_malloc(size * sizeof(uint32_t)); in sip_svc_id_mgr_create()
36 if (!id_pool->id_list) { in sip_svc_id_mgr_create()
37 k_free(id_pool); in sip_svc_id_mgr_create()
46 id_pool->id_mask = k_malloc(mask_size * sizeof(uint32_t)); in sip_svc_id_mgr_create()
47 if (!id_pool->id_mask) { in sip_svc_id_mgr_create()
48 k_free(id_pool->id_list); in sip_svc_id_mgr_create()
49 k_free(id_pool); in sip_svc_id_mgr_create()
55 id_pool->id_list[i] = i; in sip_svc_id_mgr_create()
59 id_pool->head = 0; in sip_svc_id_mgr_create()
60 id_pool->tail = size - 1; in sip_svc_id_mgr_create()
64 id_pool->id_mask[i] = 0; in sip_svc_id_mgr_create()
67 return id_pool; in sip_svc_id_mgr_create()
71 void sip_svc_id_mgr_delete(struct sip_svc_id_pool *id_pool) in sip_svc_id_mgr_delete() argument
73 if (id_pool) { in sip_svc_id_mgr_delete()
74 k_free(id_pool->id_mask); in sip_svc_id_mgr_delete()
75 k_free(id_pool->id_list); in sip_svc_id_mgr_delete()
76 k_free(id_pool); in sip_svc_id_mgr_delete()
81 uint32_t sip_svc_id_mgr_alloc(struct sip_svc_id_pool *id_pool) in sip_svc_id_mgr_alloc() argument
87 if (!id_pool) { in sip_svc_id_mgr_alloc()
91 if (id_pool->head == SIP_SVC_ID_INVALID) { in sip_svc_id_mgr_alloc()
95 id = id_pool->id_list[id_pool->head]; in sip_svc_id_mgr_alloc()
100 id_pool->id_mask[row] |= (1 << col); in sip_svc_id_mgr_alloc()
102 if (id_pool->head == id_pool->tail) { in sip_svc_id_mgr_alloc()
103 id_pool->head = SIP_SVC_ID_INVALID; in sip_svc_id_mgr_alloc()
104 id_pool->tail = SIP_SVC_ID_INVALID; in sip_svc_id_mgr_alloc()
106 id_pool->head++; in sip_svc_id_mgr_alloc()
107 if (id_pool->head == id_pool->size) { in sip_svc_id_mgr_alloc()
108 id_pool->head = 0; in sip_svc_id_mgr_alloc()
116 void sip_svc_id_mgr_free(struct sip_svc_id_pool *id_pool, uint32_t id) in sip_svc_id_mgr_free() argument
121 if (!id_pool) { in sip_svc_id_mgr_free()
125 if (id >= id_pool->size) { in sip_svc_id_mgr_free()
133 if (!(id_pool->id_mask[row] & (1 << col))) { in sip_svc_id_mgr_free()
138 id_pool->id_mask[row] &= ~(1 << col); in sip_svc_id_mgr_free()
140 if (id_pool->head == SIP_SVC_ID_INVALID) { in sip_svc_id_mgr_free()
141 id_pool->head = 0; in sip_svc_id_mgr_free()
142 id_pool->tail = 0; in sip_svc_id_mgr_free()
144 id_pool->tail++; in sip_svc_id_mgr_free()
145 if (id_pool->tail == id_pool->size) { in sip_svc_id_mgr_free()
146 id_pool->tail = 0; in sip_svc_id_mgr_free()
148 if (id_pool->head == id_pool->tail) { in sip_svc_id_mgr_free()
153 id_pool->id_list[id_pool->tail] = id; in sip_svc_id_mgr_free()