# HG changeset patch # User renatofilho # Date 1164896834 0 # Node ID 352ead2e7867899e8239852d45e5c35222467af0 # Parent f1f98329934ef4216cf4a8c9aa2bbf17d9be3ad1 [svn r145] bug fix diff -r f1f98329934e -r 352ead2e7867 gmyth/src/gmyth_uri.c --- a/gmyth/src/gmyth_uri.c Thu Nov 30 13:58:35 2006 +0000 +++ b/gmyth/src/gmyth_uri.c Thu Nov 30 14:27:14 2006 +0000 @@ -216,7 +216,7 @@ /*** Protocol ****/ protoIdx = gmyth_strstr (value, GMYTH_URI_PROTOCOL_DELIM); if (0 < protoIdx) { - uri->protocol = g_string_append_len (uri->protocol, value, protoIdx); + uri->protocol = g_string_new_len (value, protoIdx); currIdx += protoIdx + strlen( GMYTH_URI_PROTOCOL_DELIM ); } @@ -226,20 +226,20 @@ colonIdx = gmyth_strstr( value+currIdx, GMYTH_URI_COLON_DELIM ); if (0 < colonIdx && colonIdx < atIdx) { - uri->user = g_string_append_len( uri->user, value+currIdx, colonIdx ); - uri->password = g_string_append_len( uri->password, value+currIdx+colonIdx+1, atIdx-(colonIdx+1) ); + uri->user = g_string_new_len (value+currIdx, colonIdx); + uri->password = g_string_new_len (value+currIdx+colonIdx+1, atIdx - (colonIdx+1)); } - else - uri->user = g_string_append_len( uri->user, value+currIdx, atIdx - currIdx ); + else + uri->user = g_string_new_len (value+currIdx, atIdx - currIdx); currIdx += atIdx + 1; } /*** Host (Port) ****/ shashIdx = gmyth_strstr( value+currIdx, GMYTH_URI_SLASH_DELIM ); - if ( 0 < shashIdx ) - uri->host = g_string_append_len( uri->host, value+currIdx, shashIdx ); + if (0 < shashIdx) + uri->host = g_string_new_len (value+currIdx, shashIdx); else if ( gmyth_uri_isabsolute(uri) == TRUE ) - uri->host = g_string_append_len( uri->host, value+currIdx, strlen(value) - currIdx ); + uri->host = g_string_new_len (value+currIdx, strlen (value) - currIdx); host = g_strdup( gmyth_uri_get_host(uri) ); colonIdx = gmyth_strrchr (host, GMYTH_URI_COLON_DELIM, 1); eblacketIdx = gmyth_strrchr (host, GMYTH_URI_EBLACET_DELIM, 1); @@ -253,11 +253,10 @@ uri->host = g_string_insert_len (uri->host, 0, hostStr->str, colonIdx); if (0 < hostLen) { if (host[0] == '[' && host[hostLen-1] == ']') - uri->host = g_string_append_len( uri->host, hostStr->str+1, colonIdx-2 ); + uri->host = g_string_new_len (hostStr->str+1, colonIdx-2); } /**** port ****/ - portStr = g_string_new(""); - portStr = g_string_append_len( portStr, hostStr->str+colonIdx+1, hostLen-colonIdx-1 ); + portStr = g_string_new_len (hostStr->str+colonIdx+1, hostLen-colonIdx-1); uri->port = (gint)g_ascii_strtoull( portStr->str, NULL, 10 ); g_string_free( portStr, TRUE ); g_string_free( hostStr, FALSE ); @@ -291,24 +290,23 @@ } else { /* First set path simply to the rest of URI */ - g_string_append_len( uri->path, value+currIdx, uriLen-currIdx ); + uri->path = g_string_new_len (value+currIdx, uriLen-currIdx ); } /**** Path (Query/Fragment) ****/ sharpIdx = gmyth_strstr(value+currIdx, GMYTH_URI_SHARP_DELIM); if (0 < sharpIdx) { uri->path = g_string_append_len( uri->path, value+currIdx, sharpIdx); - uri->fragment = g_string_append_len( uri->fragment, - value+currIdx+sharpIdx+1, uriLen-(currIdx+sharpIdx+1)); + uri->fragment = g_string_new_len (value+currIdx+sharpIdx+1, uriLen-(currIdx+sharpIdx+1)); } questionIdx = gmyth_strstr( value+currIdx, GMYTH_URI_QUESTION_DELIM ); if ( 0 < questionIdx ) { - uri->path = g_string_append_len( uri->path, value+currIdx, questionIdx ); + uri->path = g_string_append_len (uri->path, value+currIdx, questionIdx ); queryLen = uriLen-(currIdx+questionIdx+1); if ( 0 < sharpIdx ) queryLen -= uriLen - (currIdx+sharpIdx+1); - uri->query = g_string_append_len( uri->query, value+currIdx+questionIdx+1, queryLen ); + uri->query = g_string_new_len (value+currIdx+questionIdx+1, queryLen ); } gmyth_debug( "[%s] GMythURI: host = %s, port = %d, path = %s, query = %s, fragment = %s, "\ "user = %s, password = %s.\n", __FUNCTION__, uri->host->str, uri->port,