You've already forked hexagonrpc
mirror of
https://github.com/linux-msm/hexagonrpc.git
synced 2026-02-25 13:13:52 -08:00
fastrpc: iobuffer: unwrap io buffers when decoding is complete
The decoder context stores a state that is not useful when there is no more I/O buffer decoding to be done. The I/O buffers are not only useful for decoding, but encoding as well. Replace the decoder destructor with a decoder finish function to free the encapsulating decoder context, and a generic I/O buffer destructor.
This commit is contained in:
@@ -86,6 +86,16 @@ static size_t consume_buf(struct fastrpc_decoder_context *ctx,
|
||||
return segment;
|
||||
}
|
||||
|
||||
void iobuf_free(size_t n_iobufs, struct fastrpc_io_buffer *iobufs)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n_iobufs; i++)
|
||||
free(iobufs[i].p);
|
||||
|
||||
free(iobufs);
|
||||
}
|
||||
|
||||
struct fastrpc_decoder_context *inbuf_decode_start(uint32_t sc)
|
||||
{
|
||||
struct fastrpc_decoder_context *ctx;
|
||||
@@ -114,10 +124,13 @@ err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void inbuf_decode_free(struct fastrpc_decoder_context *ctx)
|
||||
struct fastrpc_io_buffer *inbuf_decode_finish(struct fastrpc_decoder_context *ctx)
|
||||
{
|
||||
free(ctx->inbufs);
|
||||
struct fastrpc_io_buffer *inbufs = ctx->inbufs;
|
||||
|
||||
free(ctx);
|
||||
|
||||
return inbufs;
|
||||
}
|
||||
|
||||
void inbuf_decode(struct fastrpc_decoder_context *ctx, size_t len, const void *src)
|
||||
|
||||
@@ -20,8 +20,10 @@ struct fastrpc_decoder_context {
|
||||
off_t align;
|
||||
};
|
||||
|
||||
void iobuf_free(size_t n_iobufs, struct fastrpc_io_buffer *iobufs);
|
||||
|
||||
struct fastrpc_decoder_context *inbuf_decode_start(uint32_t sc);
|
||||
struct fastrpc_io_buffer *inbuf_decode_finish(struct fastrpc_decoder_context *ctx);
|
||||
void inbuf_decode(struct fastrpc_decoder_context *ctx, size_t len, const void *src);
|
||||
void inbuf_decode_free(struct fastrpc_decoder_context *ctx);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,7 @@ static int adsp_listener_next2(int fd,
|
||||
|
||||
int run_fastrpc_listener(int fd)
|
||||
{
|
||||
struct fastrpc_io_buffer *decoded = NULL;
|
||||
struct fastrpc_decoder_context *ctx;
|
||||
uint32_t result = 0xffffffff;
|
||||
uint32_t handle;
|
||||
@@ -86,7 +87,9 @@ int run_fastrpc_listener(int fd)
|
||||
|
||||
inbuf_decode(ctx, inbufs_len, inbufs);
|
||||
|
||||
inbuf_decode_free(ctx);
|
||||
decoded = inbuf_decode_finish(ctx);
|
||||
|
||||
iobuf_free(ctx);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user