Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit642c069

Browse files
committed
Remove memory leaks in isolationtester.
specscanner.l leaked a kilobyte of memory per token of the spec file.Apparently somebody thought that the introductory code block would beexecuted once; but it's once per yylex() call.A couple of functions in isolationtester.c leaked small amounts ofmemory due to not bothering to free one-time allocations. Mightas well improve these so that valgrind gives this program a cleanbill of health. Also get rid of an ugly static variable.Coverity complained about one of the one-time leaks, which led meto try valgrind'ing isolationtester, which led to discovery of thelarger leak.
1 parentc302a61 commit642c069

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static int64 max_step_wait = 300 * USECS_PER_SEC;
5252
staticvoidcheck_testspec(TestSpec*testspec);
5353
staticvoidrun_testspec(TestSpec*testspec);
5454
staticvoidrun_all_permutations(TestSpec*testspec);
55-
staticvoidrun_all_permutations_recurse(TestSpec*testspec,intnsteps,
56-
PermutationStep**steps);
55+
staticvoidrun_all_permutations_recurse(TestSpec*testspec,int*piles,
56+
intnsteps,PermutationStep**steps);
5757
staticvoidrun_named_permutations(TestSpec*testspec);
5858
staticvoidrun_permutation(TestSpec*testspec,intnsteps,
5959
PermutationStep**steps);
@@ -360,9 +360,9 @@ check_testspec(TestSpec *testspec)
360360
fprintf(stderr,"unused step name: %s\n",allsteps[i]->name);
361361
}
362362
}
363-
}
364363

365-
staticint*piles;
364+
free(allsteps);
365+
}
366366

367367
/*
368368
* Run the permutations specified in the spec, or all if none were
@@ -387,6 +387,7 @@ run_all_permutations(TestSpec *testspec)
387387
inti;
388388
PermutationStep*steps;
389389
PermutationStep**stepptrs;
390+
int*piles;
390391

391392
/* Count the total number of steps in all sessions */
392393
nsteps=0;
@@ -412,11 +413,16 @@ run_all_permutations(TestSpec *testspec)
412413
for (i=0;i<testspec->nsessions;i++)
413414
piles[i]=0;
414415

415-
run_all_permutations_recurse(testspec,0,stepptrs);
416+
run_all_permutations_recurse(testspec,piles,0,stepptrs);
417+
418+
free(steps);
419+
free(stepptrs);
420+
free(piles);
416421
}
417422

418423
staticvoid
419-
run_all_permutations_recurse(TestSpec*testspec,intnsteps,PermutationStep**steps)
424+
run_all_permutations_recurse(TestSpec*testspec,int*piles,
425+
intnsteps,PermutationStep**steps)
420426
{
421427
inti;
422428
boolfound= false;
@@ -438,7 +444,7 @@ run_all_permutations_recurse(TestSpec *testspec, int nsteps, PermutationStep **s
438444

439445
piles[i]++;
440446

441-
run_all_permutations_recurse(testspec,nsteps+1,steps);
447+
run_all_permutations_recurse(testspec,piles,nsteps+1,steps);
442448

443449
piles[i]--;
444450

‎src/test/isolation/specscanner.l

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ self[,()*]
5252
%%
5353

5454
%{
55-
litbuf = pg_malloc(LITBUF_INIT);
56-
litbufsize = LITBUF_INIT;
55+
/* Allocate litbuf in first call of yylex()*/
56+
if (litbuf ==NULL)
57+
{
58+
litbuf =pg_malloc(LITBUF_INIT);
59+
litbufsize = LITBUF_INIT;
60+
}
5761
%}
5862

5963
/* Keywords (must appear before the {identifier} rule!) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp