Created the wmud_player_dup() function

This function duplicates a wmudPlayer struct.

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI 2012-03-23 14:33:12 +01:00
parent b91ad8d87f
commit 4f601bb3dd
2 changed files with 18 additions and 0 deletions

View File

@ -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)
{

View File

@ -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__ */