Remove bogus const from rpmProblemString() return type

- its malloced so it needs to be freed
- fix all users to actually free
This commit is contained in:
Panu Matilainen 2007-12-15 11:47:47 +02:00
parent 1a0a12cf15
commit b4588a1202
5 changed files with 14 additions and 6 deletions

View File

@ -296,7 +296,7 @@ unsigned long rpmProblemGetLong(const rpmProblem p)
return (p->ulong1);
}
const char * rpmProblemString(const rpmProblem prob)
char * rpmProblemString(const rpmProblem prob)
{
const char * pkgNEVR = (prob->pkgNEVR ? prob->pkgNEVR : "?pkgNEVR?");
const char * altNEVR = (prob->altNEVR ? prob->altNEVR : "? ?altNEVR?");

View File

@ -132,7 +132,7 @@ unsigned long rpmProblemGetLong(const rpmProblem prob);
* @param prob rpm problem
* @return formatted string (malloc'd)
*/
extern const char * rpmProblemString(const rpmProblem prob);
extern char * rpmProblemString(const rpmProblem prob);
/** \ingroup rpmps
* Unreference a problem set instance.

View File

@ -371,7 +371,9 @@ static int verifyDependencies(QVA_t qva, rpmts ts,
free(nevra);
while (rpmpsNextIterator(psi) >= 0) {
rpmProblem p = rpmpsGetProblem(psi);
rpmlog(RPMLOG_NOTICE, "\t%s\n", rpmProblemString(p));
char * ps = rpmProblemString(p);
rpmlog(RPMLOG_NOTICE, "\t%s\n", ps);
free(ps);
rc++;
}
}

View File

@ -68,7 +68,9 @@ fprintf(stderr, "*** rpmps_iternext(%p) ps %p psi %p\n", s, s->ps, s->psi);
/* If more to do, return a problem set string. */
if (rpmpsNextIterator(s->psi) >= 0) {
result = Py_BuildValue("s", rpmProblemString(rpmpsGetProblem(s->psi)));
char * ps = rpmProblemString(rpmpsGetProblem(s->psi));
result = Py_BuildValue("s", ps);
free(ps);
} else {
s->psi = rpmpsFreeIterator(s->psi);
}
@ -148,7 +150,9 @@ rpmps_subscript(rpmpsObject * s, PyObject * key)
psi = rpmpsInitIterator(s->ps);
while ((i = rpmpsNextIterator(psi)) >= 0) {
if (i == ix) {
result = Py_BuildValue("s", rpmProblemString(rpmpsGetProblem(psi)));
char * ps = rpmProblemString(rpmpsGetProblem(psi));
result = Py_BuildValue("s", ps);
free(ps);
break;
}
}

View File

@ -1139,11 +1139,13 @@ fprintf(stderr, "*** rpmts_Run(%p) ts %p ignore %x\n", s, s->ts, s->ignoreSet);
psi = rpmpsInitIterator(ps);
while (rpmpsNextIterator(psi) >= 0) {
rpmProblem p = rpmpsGetProblem(psi);
PyObject * prob = Py_BuildValue("s(isN)", rpmProblemString(p),
char * ps = rpmProblemString(p);
PyObject * prob = Py_BuildValue("s(isN)", ps,
rpmProblemGetType(p),
rpmProblemGetStr(p),
PyLong_FromLongLong(rpmProblemGetLong(p)));
PyList_Append(list, prob);
free(ps);
Py_DECREF(prob);
}