Mailinglist Archive: zypp-commit (301 mails)

< Previous Next >
[zypp-commit] r7666 - in /trunk/sat-solver: src/pool.c src/solver.c testsuite/deptestomatic.c
  • From: coolo@xxxxxxxxxxxxxxxx
  • Date: Fri, 26 Oct 2007 19:08:40 -0000
  • Message-id: <20071026190840.C1680173A2@xxxxxxxxxxxxxxxx>
Author: coolo
Date: Fri Oct 26 21:08:40 2007
New Revision: 7666

URL: http://svn.opensuse.org/viewcvs/zypp?rev=7666&view=rev
Log:
fix memory leaks

Modified:
trunk/sat-solver/src/pool.c
trunk/sat-solver/src/solver.c
trunk/sat-solver/testsuite/deptestomatic.c

Modified: trunk/sat-solver/src/pool.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/pool.c?rev=7666&r1=7665&r2=7666&view=diff
==============================================================================
--- trunk/sat-solver/src/pool.c (original)
+++ trunk/sat-solver/src/pool.c Fri Oct 26 21:08:40 2007
@@ -120,6 +120,7 @@
xfree(source->rpmdbid);
xfree(source);
}
+ xfree(pool->id2arch);
xfree(pool->solvables);
xfree(pool->sources);
xfree(pool->stringspace);

Modified: trunk/sat-solver/src/solver.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/solver.c?rev=7666&r1=7665&r2=7666&view=diff
==============================================================================
--- trunk/sat-solver/src/solver.c (original)
+++ trunk/sat-solver/src/solver.c Fri Oct 26 21:08:40 2007
@@ -3066,6 +3066,8 @@
}
}
printf("------------------------------------\n");
+ queuefree(&problems);
+ queuefree(&solution);
}
return;
}

Modified: trunk/sat-solver/testsuite/deptestomatic.c
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/deptestomatic.c?rev=7666&r1=7665&r2=7666&view=diff
==============================================================================
--- trunk/sat-solver/testsuite/deptestomatic.c (original)
+++ trunk/sat-solver/testsuite/deptestomatic.c Fri Oct 26 21:08:40 2007
@@ -138,7 +138,8 @@
*/

struct _channelmap {
- Id name;
+ Id nid;
+ char *name;
Source *source;
};

@@ -175,8 +176,8 @@
enum state sbtab[NUMSTATES];
char directory[PATH_MAX];

- const char *hardwareinfo;
- const char **modaliases;
+ char *hardwareinfo;
+ char **modaliases;
int nmodaliases;
} Parsedata;

@@ -187,11 +188,11 @@
if ((pd->nmodaliases & 15) == 0)
{
if (pd->modaliases == 0)
- pd->modaliases = malloc(16 * sizeof(const char *));
+ pd->modaliases = malloc(16 * sizeof(char *));
else
- pd->modaliases = realloc(pd->modaliases, (pd->nmodaliases + 16) *
sizeof(const char *));
+ pd->modaliases = realloc(pd->modaliases, (pd->nmodaliases + 16) *
sizeof(char *));
}
- pd->modaliases[pd->nmodaliases++] = s;
+ pd->modaliases[pd->nmodaliases++] = strdup(s);
}

static void
@@ -246,7 +247,7 @@
if (l == 0)
return;
buf[l] = 0;
- add_modalias(pd, strdup(buf));
+ add_modalias(pd, buf);
}
}

@@ -255,7 +256,7 @@
{
Parsedata *pd = data;
const char *match;
- const char **m;
+ char **m;
char dir[PATH_MAX];
int i;

@@ -557,7 +558,9 @@
perror( solvname );
return NULL;
}
- return pool_addsource_solv( pd->pool, fp, strdup( name ) );
+ Source *s = pool_addsource_solv( pd->pool, fp, name );
+ fclose( fp );
+ return s;
}


@@ -629,14 +632,13 @@

if (!pd->locales)
{
- pd->locales = pool_addsource_empty(pool);
- pd->locales->name = strdup("locales");
pd->nchannels++;
pd->channels = (struct _channelmap *)realloc( pd->channels,
pd->nchannels * sizeof( struct _channelmap ) );
-
struct _channelmap *cmap = pd->channels + (pd->nchannels-1);
- cmap->name = str2id( pd->pool, "locales", 1 );
- cmap->source = pd->locales;
+
+ cmap->source = pd->locales = pool_addsource_empty(pool);
+ pd->locales->name = cmap->name = strdup( "locales" );
+ cmap->nid = str2id( pd->pool, cmap->name, 1 );
}

strcpy(locale, "language:");
@@ -764,7 +766,8 @@
if (!name)
name = file;

- Source *source = add_source( pd, name, path );
+ char *cname = strdup( name );
+ Source *source = add_source( pd, cname, path );
if (source)
{
pd->nchannels++;
@@ -775,11 +778,13 @@
abort();
}
struct _channelmap *cmap = pd->channels + (pd->nchannels-1);
- cmap->name = str2id( pool, name, 1 );
+ cmap->name = cname;
+ cmap->nid = str2id( pool, cname, 1 );
cmap->source = source;
}
else
{
+ free( cname );
err( "Can't add <channel> %s", name );
exit( 1 );
}
@@ -908,7 +913,7 @@
int i = 0;
while (i < pd->nchannels )
{
- if (pd->channels[i].name == cid)
+ if (pd->channels[i].nid == cid)
{
source = pd->channels[i].source;
break;
@@ -991,7 +996,7 @@
}
int i = 0;
while (i < pd->nchannels ) {
- if (pd->channels[i].name == cid) {
+ if (pd->channels[i].nid == cid) {
source = pd->channels[i].source;
break;
}
@@ -1342,7 +1347,23 @@
break;
}
XML_ParserFree( parser );
+ fclose( fp );
+
+ for ( i = 0; i < pd.nchannels; ++i )
+ {
+ free( pd.channels[i].name );
+ pool_freesource( pd.pool, pd.channels[i].source );
+ }
+
+ for ( i = 0; i < pd.nmodaliases; ++i )
+ free( pd.modaliases[i] );
+ free( pd.modaliases );
+
+ if ( pd.hardwareinfo)
+ free( pd.hardwareinfo );

+ pool_free( pd.pool );
+ free( pd.channels );
free( pd.content );

return 0;

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages