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

Commit6000e32

Browse files
committed
I've not changed any malloc/calloc to palloc. It looks to me that these memory
areas are for the lifetime of the backend and in the interests of not breakingsomething that's not broken I left alone.Note for anyone reading this and wanting it for tsearch-v2-stable (i.e. for 7.3backend) this patch probably will not apply cleanly to that source. It shouldbe simple enough to see what's going on and apply the changes by hand if needbe.--Nigel J. Andrews
1 parent4b4c43b commit6000e32

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

‎contrib/tsearch2/snowball/api.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,63 @@ extern struct SN_env *
66
SN_create_env(intS_size,intI_size,intB_size)
77
{
88
structSN_env*z= (structSN_env*)calloc(1,sizeof(structSN_env));
9+
structSN_env*z2=z;
10+
11+
if (!z)
12+
returnz;
913

1014
z->p=create_s();
11-
if (S_size)
15+
if (!z->p)
16+
z=NULL;
17+
18+
if (z&&S_size)
1219
{
13-
z->S= (symbol**)calloc(S_size,sizeof(symbol*));
20+
if ((z->S= (symbol**)calloc(S_size,sizeof(symbol*))))
1421
{
1522
inti;
1623

1724
for (i=0;i<S_size;i++)
18-
z->S[i]=create_s();
25+
{
26+
if (!(z->S[i]=create_s()))
27+
{
28+
z=NULL;
29+
break;
30+
}
31+
}
32+
z2->S_size=i;
1933
}
20-
z->S_size=S_size;
34+
else
35+
z=NULL;
2136
}
2237

23-
if (I_size)
38+
if (z&&I_size)
2439
{
2540
z->I= (int*)calloc(I_size,sizeof(int));
26-
z->I_size=I_size;
41+
if (z->I)
42+
z->I_size=I_size;
43+
else
44+
z=NULL;
2745
}
2846

29-
if (B_size)
47+
if (z&&B_size)
3048
{
3149
z->B= (symbol*)calloc(B_size,sizeof(symbol));
32-
z->B_size=B_size;
50+
if (z->B)
51+
z->B_size=B_size;
52+
else
53+
z=NULL;
3354
}
3455

56+
if (!z)
57+
SN_close_env(z2);
58+
3559
returnz;
3660
}
3761

3862
externvoid
3963
SN_close_env(structSN_env*z)
4064
{
41-
if (z->S_size)
65+
if (z->S&&z->S_size)
4266
{
4367
{
4468
inti;

‎contrib/tsearch2/snowball/utilities.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ create_s(void)
1414
{
1515
symbol*p= (symbol*) (HEAD+ (char*)malloc(HEAD+ (CREATE_SIZE+1)*sizeof(symbol)));
1616

17+
if (p== (symbol*) (HEAD))
18+
returnNULL;
1719
CAPACITY(p)=CREATE_SIZE;
1820
SET_SIZE(p,CREATE_SIZE);
1921
returnp;

‎contrib/tsearch2/ts_cfg.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ init_cfg(Oid id, TSCfgInfo * cfg)
112112

113113
cfg->map[lexid].len=ARRNELEMS(a);
114114
cfg->map[lexid].dict_id= (Datum*)malloc(sizeof(Datum)*cfg->map[lexid].len);
115+
if (!cfg->map[lexid].dict_id)
116+
ts_error(ERROR,"No memory");
117+
115118
memset(cfg->map[lexid].dict_id,0,sizeof(Datum)*cfg->map[lexid].len);
116119
ptr= (text*)ARR_DATA_PTR(a);
117120
oldcontext=MemoryContextSwitchTo(TopMemoryContext);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp