Changeset 10949

Show
Ignore:
Timestamp:
06/09/07 11:47:14 (2 years ago)
Author:
piotras
Message:

Free GValues initialized for argv and pages.
Added LEAK comments.
Replaced g_strdup with apr_pstrdup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/httpd/apache2/midgard-apache2.c

    r10925 r10949  
    112112        t = ap_pbase64decode(r->pool, auth_line); 
    113113 
    114         *usr = ap_getword_nulls (r->connection->pool, &t, ':'); 
    115         g_warning("USERNAME %s", *usr); 
     114        *usr = ap_getword_nulls (r->connection->pool, &t, ':');  
    116115        *pw = t; 
    117116         
     
    204203                        "name", "=", &pval); 
    205204        g_value_unset(&pval); 
    206          
     205 
     206        midgard_query_builder_set_limit(builder, 1); 
     207 
    207208        GObject **object =  
    208209                midgard_query_builder_execute(builder, NULL); 
     
    513514         
    514515        if(loaded == 0) { 
    515                 
     516         
    516517                gchar **args = { NULL }; 
    517518                gda_init ("MIDGARD", midgard_version(), 0, args); 
    518  
     519                 
    519520                scfg->mgd_hash = apr_hash_make(p); 
    520521                scfg->cfg_hash = apr_hash_make(p); 
     
    527528 
    528529                gchar **cnfnames =  
    529                         midgard_config_list_files(FALSE); 
     530                        midgard_config_list_files(FALSE); /* LEAK */ 
    530531                guint i = 0; 
    531532                 
     
    550551                        apr_pool_cleanup_register(p, (const void *) mgd, (void *)_free_mgd, NULL); 
    551552                         
    552                         midgard_config_read_file(scfg->config, cnfnames[i], FALSE); 
     553                        midgard_config_read_file(scfg->config, cnfnames[i], FALSE); /* FIXME, LEAK */ 
    553554                 
    554555                        GError *err = NULL; 
     
    564565 
    565566                        if(connected) { 
    566  
     567         
    567568                                midgard_connection_set_loglevel(mgd, scfg->config->loglevel); 
    568569                                scfg->loglevel =  
     
    570571 
    571572                                apr_hash_set(scfg->mgd_hash,  
    572                                                 (const void *) g_strdup(cnfnames[i]), 
     573                                                (const void *) apr_pstrdup(p, cnfnames[i]), 
    573574                                                APR_HASH_KEY_STRING, 
    574575                                                (const void *) mgd); 
    575576 
    576577                                apr_hash_set(scfg->cfg_hash,  
    577                                                 (const void *) g_strdup(cnfnames[i]), 
     578                                                (const void *) apr_pstrdup(p, cnfnames[i]), 
    578579                                                APR_HASH_KEY_STRING, 
    579580                                                (const void *) scfg->config); 
     
    711712         
    712713        mrs->level = midgard_connection_get_loglevel(scfg->mgd); 
    713  
     714         
    714715        g_log_set_fatal_mask("GLib-GObject", G_LOG_LEVEL_CRITICAL); 
    715716        mrs->loghandler = g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_MASK, 
     
    731732                        ap_get_server_name (r), ap_get_server_port (r), uri_prefix); 
    732733        if (!host) { 
     734                /* FIXME, free list returned from midgard_http_uri2list and uri_prefix */ 
    733735                ap_log_rerror(APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO, 0, r, 
    734736                                "Midgard: host record for %s:%d not found", 
     
    853855        guint up_id = 0; 
    854856        MidgardQueryBuilder *builder; 
    855         GObject **objects, *last_page; 
     857        GObject **objects = NULL, *last_page; 
    856858        result = MIDGARD_HTTP_FOUND_PAGE; 
    857859        gchar *info; 
     
    860862         
    861863        last_page = G_OBJECT(rootpage); 
     864        rcfg->page = last_page;  
    862865 
    863866        for ( list; list != NULL;  list = list->next) { 
     
    907910                                } 
    908911 
    909                                 g_free(objects); 
     912                                if(objects != NULL) 
     913                                        g_free(objects); 
     914                                objects = NULL; 
    910915 
    911916                        } else { 
     
    916921                                                        (const gchar *)list->data)) { 
    917922 
    918                                         //g_object_unref(rcfg); 
    919923                                        result = MIDGARD_HTTP_FOUND_BLOB; 
    920924                                        MIDGARD_HTTP_REMOVE_LOG_HANDLER(mrs); 
     
    923927                                } else { 
    924928 
     929                                        /* TODO , check if page is active or static */ 
    925930                                        result = MIDGARD_HTTP_FOUND_PAGE; 
    926931                                        goto MIDGARD_TH_SET_RCFG_DATA; 
     
    933938        GList *rp = NULL; 
    934939        guint rpi = 0; 
    935          
     940 
     941 
    936942MIDGARD_TH_SET_RCFG_DATA: 
    937943 
     
    945951        for(rp = r_pages; rp != NULL; rp = rp->next) { 
    946952                 
    947                 GValue *oval = g_new0(GValue, 1); 
     953                GValue *oval = g_new0(GValue, 1);  
    948954                g_value_init(oval, G_TYPE_OBJECT); 
    949955                g_value_set_object(oval, G_OBJECT(rp->data)); 
    950956                rcfg->pages =  
    951957                        g_value_array_append(rcfg->pages, (const GValue *)oval); 
    952  
     958                g_value_unset(oval); 
     959                g_free(oval); 
     960                 
    953961                /* FIXME FIXME FIXME */ 
    954962                /* Add boolean property value check if DB supports it */ 
    955963                gchar *info_str; 
    956964                g_object_get(G_OBJECT(rp->data), "info", &info_str, NULL); 
     965                 
    957966                if(g_str_equal(info_str, "auth")) {              
    958967                         
    959968                        rcfg->auth_required = TRUE; 
    960969                } 
     970                 
    961971                g_free(info_str); 
    962972        } 
    963973         
    964         if(last_page) 
     974        if(last_page)  
    965975                rcfg->page = last_page; 
    966976 
     
    974984                for(list; list != NULL; list = list->next) { 
    975985                         
    976                         const GValue *strval = g_new0(GValue, 1); 
     986                        GValue *strval = g_new0(GValue, 1);  
    977987                        g_value_init((GValue *)strval, G_TYPE_STRING); 
    978988                        g_value_set_string((GValue *)strval, (gchar *)list->data); 
    979                         array = g_value_array_append(array, strval); 
     989                        array = g_value_array_append(array, (const GValue *)strval); 
     990                        g_value_unset(strval); 
     991                        g_free(strval);                  
    980992                        g_free(list->data); 
    981  
    982993                } 
    983994 
     
    9981009        if(list)  
    9991010                g_list_free(list); 
     1011 
     1012        /* Free pages list */ 
     1013        if(r_pages)  
     1014                g_list_free(r_pages); 
    10001015 
    10011016        /* TODO */