return 0;
}
+/* Write the SFrame FRE start address from the in-memory FRE_START_ADDR
+ to the buffer CONTENTS (on-disk format), given the FRE_TYPE and
+ FRE_START_ADDR_SZ. */
+
+static int
+sframe_encoder_write_fre_start_addr (char *contents,
+ uint32_t fre_start_addr,
+ unsigned int fre_type,
+ size_t fre_start_addr_sz)
+{
+ int err = 0;
+
+ if (fre_type == SFRAME_FRE_TYPE_ADDR1)
+ {
+ uint8_t uc = fre_start_addr;
+ memcpy (contents, &uc, fre_start_addr_sz);
+ }
+ else if (fre_type == SFRAME_FRE_TYPE_ADDR2)
+ {
+ uint16_t ust = fre_start_addr;
+ memcpy (contents, &ust, fre_start_addr_sz);
+ }
+ else if (fre_type == SFRAME_FRE_TYPE_ADDR4)
+ {
+ uint32_t uit = fre_start_addr;
+ memcpy (contents, &uit, fre_start_addr_sz);
+ }
+ else
+ return sframe_set_errno (&err, SFRAME_ERR_INVAL);
+
+ return 0;
+}
+
/* Write a frame row entry pointed to by FREP into the buffer CONTENTS. The
size in bytes written out are updated in ESZ.
uint64_t bitmask = SFRAME_BITMASK_OF_SIZE (fre_start_addr_sz);
sframe_assert ((uint64_t)frep->fre_start_addr <= bitmask);
- memcpy (contents,
- &frep->fre_start_addr,
- fre_start_addr_sz);
+ sframe_encoder_write_fre_start_addr (contents, frep->fre_start_addr,
+ fre_type, fre_start_addr_sz);
contents += fre_start_addr_sz;
memcpy (contents,