* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
#include <glib.h>
#include <fcntl.h>
+#if !defined(G_OS_WIN32) || !defined(_MSC_VER)
#include <unistd.h>
+#endif
#include <string.h>
GvdbItem *parent;
GvdbItem *sibling;
GvdbItem *next;
- GVariant *options;
/* one of:
* this:
if (item->value)
g_variant_unref (item->value);
- if (item->options)
- g_variant_unref (item->options);
-
if (item->table)
g_hash_table_unref (item->table);
guint32 hash_value = 5381;
while (*key)
- hash_value = hash_value * 33 + *key++;
+ hash_value = hash_value * 33 + *(signed char *)key++;
return hash_value;
}
}
void
-gvdb_item_set_options (GvdbItem *item,
- GVariant *options)
-{
- g_return_if_fail (!item->options);
-
- item->options = g_variant_ref_sink (options);
-}
-
-void
gvdb_item_set_hash_table (GvdbItem *item,
GHashTable *table)
{
gint n_buckets;
} HashTable;
-HashTable *
+static HashTable *
hash_table_new (gint n_buckets)
{
HashTable *table;
}
static void
+hash_table_free (HashTable *table)
+{
+ g_free (table->buckets);
+
+ g_slice_free (HashTable, table);
+}
+
+static void
hash_table_insert (gpointer key,
gpointer value,
gpointer data)
}
static void
-file_builder_add_options (FileBuilder *fb,
- GVariant *options,
- struct gvdb_pointer *pointer)
-{
- GVariant *normal;
- gpointer data;
- gsize size;
-
- if (options)
- {
- if (fb->byteswap)
- {
- options = g_variant_byteswap (options);
- normal = g_variant_get_normal_form (options);
- g_variant_unref (options);
- }
- else
- normal = g_variant_get_normal_form (options);
-
- size = g_variant_get_size (normal);
- data = file_builder_allocate (fb, 8, size, pointer);
- g_variant_store (normal, data);
- g_variant_unref (normal);
- }
-}
-
-static void
file_builder_add_string (FileBuilder *fb,
const gchar *string,
guint32_le *start,
g_assert (item->child == NULL && item->table == NULL);
file_builder_add_value (fb, item->value, &entry->value.pointer);
- file_builder_add_options (fb, item->options, &entry->options);
entry->type = 'v';
}
if (item->child != NULL)
{
- guint32 children = 0;
+ guint32 children = 0, i = 0;
guint32_le *offsets;
GvdbItem *child;
entry->type = 'L';
for (child = item->child; child; child = child->sibling)
- offsets[--children] = child->assigned_index;
+ offsets[i++] = child->assigned_index;
- g_assert (children == 0);
+ g_assert (children == i);
}
if (item->table != NULL)
index++;
}
}
+
+ hash_table_free (mytable);
}
static FileBuilder *
g_string_append_len (result, chunk->data, chunk->size);
g_free (chunk->data);
+
+ g_slice_free (FileChunk, chunk);
}
g_queue_free (fb->chunks);