在 ERPC 的 IDL 说明文档中,对于接口内存的申请和释放是这样描述的:
- On the client side: All memory space has to be allocated and provided by the user code. The shim code only reads from or writes into this memory space.
- On the server side: All memory space is allocated and provided by the shim code. The user code only reads from or writes into this memory space.
为了避免在实际使用中产生内存泄漏,还是需要实际查看代码来理解。
其实这里分两种情况:
- 以指针作为返回参数
- 以指针作为形参