/* SFrame header. */
sframe_header sfd_header;
/* SFrame function desc entries table. */
- uint32_t *sfd_funcdesc;
+ sframe_func_desc_entry *sfd_funcdesc;
/* SFrame FRE table. */
- void *sfd_fres;
+ char *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
void *sfd_buf;
};
+typedef struct sf_fde_tbl sf_fde_tbl;
+typedef struct sf_fre_tbl sf_fre_tbl;
+
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. */
+ /* SFrame header. */
+ sframe_header sfe_header;
+ /* SFrame function desc entries table. */
+ sf_fde_tbl *sfe_funcdesc;
+ /* SFrame FRE table. */
+ sf_fre_tbl *sfe_fres;
+ /* Number of bytes needed for SFrame FREs. */
+ uint32_t sfe_fre_nbytes;
+ /* SFrame output data buffer. */
+ char *sfe_data;
+ /* Size of the SFrame output data buffer. */
+ size_t sfe_data_size;
};
#ifdef __cplusplus
#include "sframe-impl.h"
#include "swap.h"
-typedef struct sf_funidx_tbl
+struct sf_fde_tbl
{
unsigned int count;
unsigned int alloced;
sframe_func_desc_entry entry[1];
-} sf_funidx_tbl;
+};
-typedef struct sf_fre_tbl
+struct sf_fre_tbl
{
unsigned int count;
unsigned int alloced;
sframe_frame_row_entry entry[1];
-} sf_fre_tbl;
+};
#define _sf_printflike_(string_index,first_to_check) \
__attribute__ ((__format__ (__printf__, (string_index), (first_to_check))))
frame_buf += (fidx_size);
/* Handle the SFrame Frame Row Entry section. */
- dctx->sfd_fres = malloc (sfheaderp->sfh_fre_len);
+ dctx->sfd_fres = (char *) malloc (sfheaderp->sfh_fre_len);
if (dctx->sfd_fres == NULL)
{
sframe_ret_set_errno (errp, SFRAME_ERR_NOMEM);
sframe_func_desc_entry *fde = NULL;
if (func_idx < sframe_encoder_get_num_fidx (encoder))
{
- sf_funidx_tbl *func_tbl = (sf_funidx_tbl *) encoder->sfe_funcdesc;
+ sf_fde_tbl *func_tbl = encoder->sfe_funcdesc;
fde = func_tbl->entry + func_idx;
}
return fde;
return sframe_set_errno (&err, SFRAME_ERR_FDE_NOTFOUND);
fre_type = sframe_get_fre_type (fdep);
- sf_fre_tbl *fre_tbl = (sf_fre_tbl *) encoder->sfe_fres;
+ sf_fre_tbl *fre_tbl = encoder->sfe_fres;
if (fre_tbl == NULL)
{
esz = sframe_fre_entry_size (frep, fre_type);
fre_tbl->count++;
- encoder->sfe_fres = (void *) fre_tbl;
+ encoder->sfe_fres = fre_tbl;
encoder->sfe_fre_nbytes += esz;
ehp = sframe_encoder_get_header (encoder);
uint32_t num_fres __attribute__ ((unused)))
{
sframe_header *ehp;
- sf_funidx_tbl *fd_info;
+ sf_fde_tbl *fd_info;
size_t fd_tbl_sz;
int err = 0;
if (encoder == NULL)
return sframe_set_errno (&err, SFRAME_ERR_INVAL);
- fd_info = (sf_funidx_tbl *) encoder->sfe_funcdesc;
+ fd_info = encoder->sfe_funcdesc;
ehp = sframe_encoder_get_header (encoder);
if (fd_info == NULL)
{
- fd_tbl_sz = (sizeof (sf_funidx_tbl)
+ fd_tbl_sz = (sizeof (sf_fde_tbl)
+ (number_of_entries * sizeof (sframe_func_desc_entry)));
fd_info = malloc (fd_tbl_sz);
if (fd_info == NULL)
}
else if (fd_info->count == fd_info->alloced)
{
- fd_tbl_sz = (sizeof (sf_funidx_tbl)
+ fd_tbl_sz = (sizeof (sf_fde_tbl)
+ ((fd_info->alloced + number_of_entries)
* sizeof (sframe_func_desc_entry)));
fd_info = realloc (fd_info, fd_tbl_sz);
#endif
fd_info->entry[fd_info->count].sfde_func_info = func_info;
fd_info->count++;
- encoder->sfe_funcdesc = (void *) fd_info;
+ encoder->sfe_funcdesc = fd_info;
ehp->sfh_num_fdes++;
return 0;
ehp = sframe_encoder_get_header (encoder);
/* Sort and write out the FDE table. */
- sf_funidx_tbl *fd_info = (sf_funidx_tbl *) encoder->sfe_funcdesc;
+ sf_fde_tbl *fd_info = encoder->sfe_funcdesc;
if (fd_info)
{
qsort (fd_info->entry, fd_info->count,
size_t esz = 0;
sframe_header *ehp;
unsigned char flags;
- sf_funidx_tbl *fd_info;
+ sf_fde_tbl *fd_info;
sf_fre_tbl *fr_info;
uint32_t i, num_fdes;
uint32_t j, num_fres;
ehp = sframe_encoder_get_header (encoder);
hdr_size = sframe_get_hdr_size (ehp);
- fd_info = (sf_funidx_tbl *) encoder->sfe_funcdesc;
- fr_info = (sf_fre_tbl *) encoder->sfe_fres;
+ fd_info = encoder->sfe_funcdesc;
+ fr_info = encoder->sfe_fres;
/* Sanity checks:
- buffers must be malloc'd by the caller. */