MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / erpc_server_init

Function erpc_server_init

erpc_c/setup/erpc_server_setup.cpp:35–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33////////////////////////////////////////////////////////////////////////////////
34
35erpc_server_t erpc_server_init(erpc_transport_t transport, erpc_mbf_t message_buffer_factory)
36{
37 erpc_assert(transport != NULL);
38 erpc_assert(message_buffer_factory != NULL);
39
40 Transport *castedTransport;
41 BasicCodecFactory *codecFactory;
42 Crc16 *crc16;
43 SimpleServer *simpleServer;
44
45#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
46 if (s_codecFactory.isUsed() || s_crc16.isUsed() || s_server.isUsed())
47 {
48 simpleServer = NULL;
49 }
50 else
51 {
52 // Init factories.
53 s_codecFactory.construct();
54 codecFactory = s_codecFactory.get();
55
56 s_crc16.construct();
57 crc16 = s_crc16.get();
58
59 // Init the client manager.
60 s_server.construct();
61 simpleServer = s_server.get();
62 }
63#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
64 // Init factories.
65 codecFactory = new BasicCodecFactory();
66
67 crc16 = new Crc16();
68
69 // Init the client manager.
70 simpleServer = new SimpleServer();
71
72 if ((codecFactory == NULL) || (crc16 == NULL) || (simpleServer == NULL))
73 {
74 if (codecFactory != NULL)
75 {
76 delete codecFactory;
77 }
78 if (crc16 != NULL)
79 {
80 delete crc16;
81 }
82 if (simpleServer != NULL)
83 {
84 delete simpleServer;
85 }
86 simpleServer = NULL;
87 }
88#else
89#error "Unknown eRPC allocation policy!"
90#endif
91
92 if (simpleServer != NULL)

Callers 14

runInitFunction · 0.85
runInitFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
runInitFunction · 0.85
runInitFunction · 0.85
runInitFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 5

isUsedMethod · 0.80
constructMethod · 0.80
setTransportMethod · 0.80
getMethod · 0.45
setCrc16Method · 0.45

Tested by 8

runInitFunction · 0.68
runInitFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
runInitFunction · 0.68
runInitFunction · 0.68
runInitFunction · 0.68
mainFunction · 0.68