1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
25
26
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
57
58
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
91
92
93
94
97
98
99
100
101
102
103
104
105
106
107
108
109
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
142
143
144
145
/* ... */
/* ... */
#include <string.h>
#include "stack/bt_types.h"
#include "common/bt_target.h"
#include "stack/avct_api.h"
#include "avct_int.h"5 includes
#if (defined(AVCT_INCLUDED) && AVCT_INCLUDED == TRUE)
/* ... */
tAVCT_CCB *avct_ccb_alloc(tAVCT_CC *p_cc)
{
tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
int i;
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
if (!p_ccb->allocated) {
p_ccb->allocated = AVCT_ALOC_LCB;
memcpy(&p_ccb->cc, p_cc, sizeof(tAVCT_CC));
AVCT_TRACE_DEBUG("avct_ccb_alloc %d", i);
break;
}{...}
}{...}
if (i == AVCT_NUM_CONN) {
p_ccb = NULL;
AVCT_TRACE_WARNING("Out of ccbs");
}{...}
return p_ccb;
}{...}
/* ... */
void avct_ccb_dealloc(tAVCT_CCB *p_ccb, UINT8 event, UINT16 result, BD_ADDR bd_addr)
{
tAVCT_CTRL_CBACK *p_cback = p_ccb->cc.p_ctrl_cback;
AVCT_TRACE_DEBUG("avct_ccb_dealloc %d", avct_ccb_to_idx(p_ccb));
#if (AVCT_BROWSE_INCLUDED == TRUE)
if (p_ccb->p_bcb == NULL) {
memset(p_ccb, 0, sizeof(tAVCT_CCB));
}{...} else {
avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_UNBIND_EVT, (tAVCT_LCB_EVT *) &p_ccb);
p_ccb->p_lcb = NULL;
}{...}
/* ... */#else
memset(p_ccb, 0, sizeof(tAVCT_CCB));
#endif
if (event != AVCT_NO_EVT) {
(*p_cback)(avct_ccb_to_idx(p_ccb), event, result, bd_addr);
}{...}
}{...}
/* ... */
UINT8 avct_ccb_to_idx(tAVCT_CCB *p_ccb)
{
return (UINT8) (p_ccb - avct_cb.ccb);
}{...}
/* ... */
tAVCT_CCB *avct_ccb_by_idx(UINT8 idx)
{
tAVCT_CCB *p_ccb;
if (idx < AVCT_NUM_CONN) {
p_ccb = &avct_cb.ccb[idx];
if (!p_ccb->allocated) {
p_ccb = NULL;
AVCT_TRACE_WARNING("ccb %d not allocated", idx);
}{...}
}{...} else {
p_ccb = NULL;
AVCT_TRACE_WARNING("No ccb for idx %d", idx);
}{...}
return p_ccb;
}{...}
/* ... */
#endif