Fix memory leak in video_output on Mac OS X (close #6267)
[vlc/solaris.git] / src / misc / sql.c
blob591ab598f433aa310c98378612a2f0785406466e
1 /*****************************************************************************
2 * sql.c: SQL Connection: Creators and destructors
3 *****************************************************************************
4 * Copyright (C) 2008-2009 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Srikanth Raju <srikiraju at gmail dot com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
28 #include <vlc_common.h>
29 #include <vlc_sql.h>
30 #include <vlc_modules.h>
31 #include <assert.h>
32 #include "libvlc.h"
34 #undef sql_Create
35 sql_t *sql_Create( vlc_object_t *p_this, const char *psz_name,
36 const char* psz_host, int i_port,
37 const char* psz_user, const char* psz_pass )
39 sql_t *p_sql;
41 p_sql = ( sql_t * ) vlc_custom_create( p_this, sizeof( sql_t ), "sql" );
42 if( !p_sql )
44 msg_Err( p_this, "unable to create sql object" );
45 return NULL;
48 p_sql->psz_host = strdup( psz_host );
49 p_sql->psz_user = strdup( psz_user );
50 p_sql->psz_pass = strdup( psz_pass );
51 p_sql->i_port = i_port;
53 p_sql->p_module = module_need( p_sql, "sql", psz_name,
54 psz_name && *psz_name );
55 if( !p_sql->p_module )
57 free( p_sql->psz_host );
58 free( p_sql->psz_user );
59 free( p_sql->psz_pass );
60 vlc_object_release( p_sql );
61 msg_Err( p_this, "SQL provider not found" );
62 return NULL;
65 return p_sql;
68 #undef sql_Destroy
69 void sql_Destroy( vlc_object_t* obj )
71 sql_t *p_sql = (sql_t *)obj;
72 assert( p_sql );
74 free( p_sql->psz_host );
75 free( p_sql->psz_user );
76 free( p_sql->psz_pass );
78 module_unneed( p_sql, p_sql->p_module );
80 vlc_object_release( obj );