Exemplo n.º 1
0
static gboolean
_deserialize_dynamic_entries(SerializeArchive *sa, NVTable *res)
{
  NVIndexEntry *index_table;

  index_table = nv_table_get_index(res);
  if (!serialize_read_uint32_array(sa, (guint32 *) index_table, res->index_size * 2))
    return FALSE;
  return TRUE;
}
Exemplo n.º 2
0
static void
_write_struct(SerializeArchive *sa, NVTable *self)
{
  serialize_write_uint32(sa, self->size);
  serialize_write_uint32(sa, self->used);
  serialize_write_uint16(sa, self->index_size);
  serialize_write_uint8(sa, self->num_static_entries);
  serialize_write_uint32_array(sa, self->static_entries, self->num_static_entries);
  serialize_write_uint32_array(sa, (guint32 *) nv_table_get_index(self), self->index_size * 2);
}
Exemplo n.º 3
0
static gboolean
_deserialize_blob_v22(SerializeArchive *sa, NVTable *self, gchar *table_top,
                      gboolean different_endianness)
{
  GString *old_nvtable_payload;
  gchar *current_payload_pointer = table_top;
  int i;
  NVIndexEntry *dyn_entries;

  if (!self->used)
    return TRUE;

  old_nvtable_payload = g_string_sized_new(self->used);
  old_nvtable_payload->len = self->used;

  if (!serialize_read_blob(sa, old_nvtable_payload->str, self->used))
    {
      g_string_free(old_nvtable_payload, TRUE);
      return FALSE;
    }

  /*
   * Iterate through all NVEntries and convert them. We should update
   * their offset, too. We do not need to iterate them in order, we
   * will simply copy them to the new place linearly. The only problem
   * is that the indirect/direct use-case should be resolved
   * correctly.
   */

  for (i = 0; i < self->num_static_entries; i++)
    {
      guint32 old_entry_offset = self->static_entries[i];

      if (old_entry_offset != 0)
        {
          NVEntry *new_entry =
            _deserialize_old_entry(old_nvtable_payload, old_entry_offset,
                                   current_payload_pointer, different_endianness);

          self->static_entries[i] = (guint32)(table_top - (gchar *)new_entry);
          current_payload_pointer = current_payload_pointer - new_entry->alloc_len;
        }
    }

  dyn_entries = nv_table_get_index(self);
  for (i = 0; i < self->index_size; i++)
    {
      NVIndexEntry *dynvalue = &dyn_entries[i];
      guint32 old_entry_offset = dynvalue->ofs;
      NVEntry *new_entry =
        _deserialize_old_entry(old_nvtable_payload, old_entry_offset,
                               current_payload_pointer, different_endianness);

      dynvalue->ofs = (guint32) (table_top - (gchar *) new_entry);
      current_payload_pointer = current_payload_pointer - new_entry->alloc_len;
    }

  self->used = table_top - current_payload_pointer;

  g_string_free(old_nvtable_payload, TRUE);
  return TRUE;
}