summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <sandmann@daimi.au.dk>2009-04-19 15:02:04 -0400
committerSøren Sandmann Pedersen <sandmann@daimi.au.dk>2009-04-19 15:02:04 -0400
commitca68ce365a12a06f633ad0261d00dc1fbc8fd93e (patch)
treea0d79a3b639eaa79b65c5fd44d96f9609f3fc1c2
parent59289ffaf96f5db926755f97dc83e17b63836013 (diff)
Get rid of pointer arrays
-rw-r--r--array.c51
-rw-r--r--dbus.c30
-rw-r--r--libnul.h10
3 files changed, 15 insertions, 76 deletions
diff --git a/array.c b/array.c
index f8341c0..df5a293 100644
--- a/array.c
+++ b/array.c
@@ -241,57 +241,6 @@ nul_garray_len (const nul_ptr_t array)
return array_len (array, &arr_t_magic);
}
-/* Pointer arrays. The idiomatic way to iterate through such an array is:
- *
- * void **p;
- *
- * for (p = array; *p; ++p)
- * {
- * my_type_t *my = *p;
- *
- * ...;
- * }
- *
- * They are always nul terminated. If there are embedded nulls in the array, then
- * this should be used instead:
- *
- * int i;
- *
- * for (i = 0; i < nul_parr_len (array); ++i)
- * {
- * my_type_t *my = array[i];
- *
- * ...;
- * }
- *
- */
-
-static const int parr_t_magic;
-
-void **
-nul_ptr_array_new (void)
-{
- return array_new (sizeof (void *), &parr_t_magic, 0);
-}
-
-void **
-nul_ptr_array_append (void **arr, nul_ptr_t data)
-{
- return array_append (arr, &parr_t_magic, &data);
-}
-
-void
-nul_ptr_array_free (void **arr)
-{
- array_free (arr, &parr_t_magic);
-}
-
-gsize
-nul_ptr_array_len (const nul_ptr_t *arr)
-{
- return array_len (arr, &parr_t_magic);
-}
-
/*
* Strings
*/
diff --git a/dbus.c b/dbus.c
index 7c69d9d..f1d7e56 100644
--- a/dbus.c
+++ b/dbus.c
@@ -314,9 +314,9 @@ do_free (gpointer data)
func (*(p + 1));
}
- nul_ptr_array_free (free_us);
+ nul_array_free (free_us);
- free_us = nul_ptr_array_new ();
+ free_us = nul_array_new (nul_ptr_t);
idle_handler = 0;
@@ -327,13 +327,13 @@ static gpointer
idle_free (gpointer p, nul_free_func_t free_func)
{
if (!free_us)
- free_us = nul_ptr_array_new ();
+ free_us = nul_array_new (nul_ptr_t);
if (free_func)
- free_us = nul_ptr_array_append (free_us, free_func);
+ free_us = nul_array_append (free_us, (void *)free_func);
else
- free_us = nul_ptr_array_append (free_us, g_free);
- free_us = nul_ptr_array_append (free_us, p);
+ free_us = nul_array_append (free_us, (void *)g_free);
+ free_us = nul_array_append (free_us, p);
if (!idle_handler)
idle_handler = g_idle_add (do_free, NULL);
@@ -688,17 +688,17 @@ static const DBusObjectPathVTable vtable =
static nul_ptr_t *
make_ptr_array (gpointer first, va_list parameters)
{
- nul_ptr_t *array = nul_ptr_array_new ();
+ nul_ptr_t *array = nul_array_new (nul_ptr_t);
gpointer v;
if (first)
{
- array = nul_ptr_array_append (array, first);
+ array = nul_array_append (array, first);
v = va_arg (parameters, gpointer);
while (v)
{
- array = nul_ptr_array_append (array, v);
+ array = nul_array_append (array, v);
v = va_arg (parameters, gpointer);
}
@@ -941,8 +941,8 @@ nul_dbus_object (const char *name,
* still add it here so that introspection can treat the introspection
* interface as any other interface
*/
- object->interfaces = nul_ptr_array_append (
- object->interfaces, nul_dbus_interface (
+ object->interfaces = nul_array_append (
+ object->interfaces, (void *)nul_dbus_interface (
"org.freedesktop.DBus.Introspectable",
nul_dbus_method (
"Introspect",
@@ -1015,10 +1015,10 @@ make_fun_def (nul_dbus_member_t *member)
int i;
types = idle_free (g_new0 (nul_type_t,
- nul_ptr_array_len (member->parameters) + 1), NULL);
+ nul_array_len (member->parameters) + 1), NULL);
types[0] = NUL_TYPE_POINTER; /* For object->data */
- for (i = 1; i < nul_ptr_array_len (member->parameters); ++i)
+ for (i = 1; i < nul_array_len (member->parameters); ++i)
{
nul_dbus_parameter_t *par = member->parameters[i - 1];
@@ -1029,7 +1029,7 @@ make_fun_def (nul_dbus_member_t *member)
}
return nul_fun_def_new (NUL_TYPE_INT,
- nul_ptr_array_len (member->parameters) + 1,
+ nul_array_len (member->parameters) + 1,
types);
}
@@ -1041,7 +1041,7 @@ make_reply_fun (nul_dbus_member_t *member)
int n;
types = idle_free (g_new0 (nul_type_t,
- nul_ptr_array_len (member->parameters) + 2), NULL);
+ nul_array_len (member->parameters) + 2), NULL);
n = 0;
for (p = member->parameters; *p; ++p)
diff --git a/libnul.h b/libnul.h
index 766ea95..413d535 100644
--- a/libnul.h
+++ b/libnul.h
@@ -76,16 +76,6 @@ void nul_garray_free (nul_ptr_t array);
_nul_prefix_array_free_impl(array,member)
/*
- * Pointer arrays
- */
-nul_ptr_t *nul_ptr_array_new (void) NUL_UR;
-nul_ptr_t *nul_ptr_array_append (nul_ptr_t *arr,
- nul_ptr_t data) NUL_UR;
-gsize nul_ptr_array_len (nul_const_ptr_t *arr);
-void nul_ptr_array_free (nul_ptr_t *arr);
-
-
-/*
* Strings
*/
typedef char nul_string_t;