Allocate spec line buffer separately from spec struct

- Further preliminaries for dynamic buffer resizing
This commit is contained in:
Panu Matilainen 2012-07-31 11:52:51 +03:00
parent 0c737f72b2
commit 729fd554ee
3 changed files with 6 additions and 2 deletions

View File

@ -203,7 +203,7 @@ static int copyNextLineFromOFI(rpmSpec spec, OFI_t *ofi)
/* Don't expand macros (eg. %define) in false branch of %if clause */
if (spec->readStack->reading &&
expandMacros(spec, spec->macros, spec->lbuf, sizeof(spec->lbuf))) {
expandMacros(spec, spec->macros, spec->lbuf, spec->lbufSize)) {
rpmlog(RPMLOG_ERR, _("line %d: %s\n"),
spec->lineNum, spec->lbuf);
return -1;

View File

@ -41,7 +41,8 @@ struct rpmSpec_s {
const char * rootDir;
struct OpenFileInfo * fileStack;
char lbuf[10*BUFSIZ];
char *lbuf;
size_t lbufSize;
size_t lbufOff;
char nextpeekc;
char * nextline;

View File

@ -160,6 +160,8 @@ rpmSpec newSpec(void)
spec->specFile = NULL;
spec->fileStack = NULL;
spec->lbufSize = BUFSIZ * 10;
spec->lbuf = xmalloc(spec->lbufSize);
spec->lbuf[0] = '\0';
spec->line = spec->lbuf;
spec->nextline = NULL;
@ -237,6 +239,7 @@ rpmSpec rpmSpecFree(rpmSpec spec)
rl->next = NULL;
free(rl);
}
spec->lbuf = _free(spec->lbuf);
spec->sourceRpmName = _free(spec->sourceRpmName);
spec->sourcePkgId = _free(spec->sourcePkgId);