1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2002-2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Authors: Martyn Russell <martyn@imendio.com>
21 * Xavier Claessens <xclaesse@gmail.com>
26 #include "gossip-avatar.h"
28 #define DEBUG_DOMAIN "Avatar"
31 gossip_avatar_get_gtype (void)
33 static GType type_id = 0;
36 type_id = g_boxed_type_register_static ("GossipAvatar",
37 (GBoxedCopyFunc) gossip_avatar_ref,
38 (GBoxedFreeFunc) gossip_avatar_unref);
45 gossip_avatar_new (guchar *data,
51 g_return_val_if_fail (data != NULL, NULL);
52 g_return_val_if_fail (len > 0, NULL);
53 g_return_val_if_fail (format != NULL, NULL);
55 avatar = g_slice_new0 (GossipAvatar);
56 avatar->data = g_memdup (data, len);
58 avatar->format = g_strdup (format);
65 gossip_avatar_unref (GossipAvatar *avatar)
67 g_return_if_fail (avatar != NULL);
70 if (avatar->refcount == 0) {
71 g_free (avatar->data);
72 g_free (avatar->format);
73 g_slice_free (GossipAvatar, avatar);
78 gossip_avatar_ref (GossipAvatar *avatar)
80 g_return_val_if_fail (avatar != NULL, NULL);