mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-11 13:02:10 +08:00
sframe_decode () needs to malloc a temporary buffer of the same size as the input buffer (containing the SFrame section bytes) when endian flipping is needed. The decoder keeps the endian flipped contents in this buffer for its usage. This code is necessary when the target endianneess is not the same as host endianness. The malloc'd buffer needs to be kept track of, so that it can freed up in sframe_decoder_free () later. ChangeLog: * libsframe/sframe-impl.h (struct sframe_decoder_ctx): Add new member to keep track of the internally malloc'd buffer. * libsframe/sframe.c (sframe_decoder_free): Free it up. (sframe_decode): Update the reference to the buffer.
63 lines
1.8 KiB
C
63 lines
1.8 KiB
C
/* Implementation header.
|
|
|
|
Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
|
This file is part of libsframe.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef _SFRAME_IMPL_H
|
|
#define _SFRAME_IMPL_H
|
|
|
|
#include "sframe-api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include <assert.h>
|
|
#define sframe_assert(expr) (assert (expr))
|
|
|
|
struct sframe_decoder_ctx
|
|
{
|
|
/* SFrame header. */
|
|
sframe_header sfd_header;
|
|
/* SFrame function desc entries table. */
|
|
uint32_t *sfd_funcdesc;
|
|
/* SFrame FRE table. */
|
|
void *sfd_fres;
|
|
/* Number of bytes needed for SFrame FREs. */
|
|
int sfd_fre_nbytes;
|
|
/* Reference to the internally malloc'd buffer, if any, for endian flipping
|
|
the original input buffer before decoding. */
|
|
void *sfd_buf;
|
|
};
|
|
|
|
struct sframe_encoder_ctx
|
|
{
|
|
sframe_header sfe_header; /* SFrame header. */
|
|
uint32_t *sfe_funcdesc; /* SFrame function desc entries table. */
|
|
sframe_frame_row_entry *sfe_fres; /* SFrame FRE table. */
|
|
uint32_t sfe_fre_nbytes; /* Number of bytes needed for SFrame FREs. */
|
|
char *sfe_data; /* SFrame data buffer. */
|
|
size_t sfe_data_size; /* Size of the SFrame data buffer. */
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _SFRAME_IMPL_H */
|