* the %G_SOCKET_ADDRESS_UNIX family by using g_socket_send_message()
* and received using g_socket_receive_message().
*
- * Note that <filename><gio/gunixfdlist.h></filename> belongs to
- * the UNIX-specific GIO interfaces, thus you have to use the
- * <filename>gio-unix-2.0.pc</filename> pkg-config file when using it.
+ * Note that `<gio/gunixfdlist.h>` belongs to the UNIX-specific GIO
+ * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
+ * file when using it.
*/
#include "config.h"
-#include <sys/types.h>
-#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "gunixfdlist.h"
+#include "gnetworking.h"
#include "gioerror.h"
-
-
-G_DEFINE_TYPE (GUnixFDList, g_unix_fd_list, G_TYPE_OBJECT)
-
struct _GUnixFDListPrivate
{
gint *fds;
gint nfd;
};
+G_DEFINE_TYPE_WITH_PRIVATE (GUnixFDList, g_unix_fd_list, G_TYPE_OBJECT)
+
static void
g_unix_fd_list_init (GUnixFDList *list)
{
- list->priv = G_TYPE_INSTANCE_GET_PRIVATE (list,
- G_TYPE_UNIX_FD_LIST,
- GUnixFDListPrivate);
+ list->priv = g_unix_fd_list_get_instance_private (list);
}
static void
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- g_type_class_add_private (class, sizeof (GUnixFDListPrivate));
object_class->finalize = g_unix_fd_list_finalize;
}
list->priv->fds = g_new (gint, n_fds + 1);
list->priv->nfd = n_fds;
- memcpy (list->priv->fds, fds, sizeof (gint) * n_fds);
+ if (n_fds > 0)
+ memcpy (list->priv->fds, fds, sizeof (gint) * n_fds);
list->priv->fds[n_fds] = -1;
return list;