From 4f601bb3dddb3f5b8dd2d1dd4b0a13350af08005 Mon Sep 17 00:00:00 2001 From: Gergely POLONKAI Date: Fri, 23 Mar 2012 14:33:12 +0100 Subject: [PATCH] Created the wmud_player_dup() function This function duplicates a wmudPlayer struct. Signed-off-by: Gergely POLONKAI --- src/players.c | 17 +++++++++++++++++ src/players.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/players.c b/src/players.c index dc5eaa2..1e98a83 100644 --- a/src/players.c +++ b/src/players.c @@ -59,6 +59,23 @@ wmud_player_exists(gchar *player_name) } +wmudPlayer * +wmud_player_dup(wmudPlayer *player) +{ + wmudPlayer *new_player; + + if (!player) + return NULL; + + new_player = g_new0(wmudPlayer, 1); + new_player->id = player->id; + new_player->player_name = g_strdup(player->player_name); + new_player->cpassword = g_strdup(player->cpassword); + new_player->email = g_strdup(player->email); + + return new_player; +} + void wmud_player_free(wmudPlayer **player) { diff --git a/src/players.h b/src/players.h index a9cdbb9..b3373bc 100644 --- a/src/players.h +++ b/src/players.h @@ -28,5 +28,6 @@ extern GSList *players; gboolean wmud_player_auth(wmudClient *client); wmudPlayer *wmud_player_exists(gchar *player_name); void wmud_player_free(wmudPlayer **player); +wmudPlayer *wmud_player_dup(wmudPlayer *player); #endif /* __WMUD_PLAYERS_H__ */