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

Commita11142e

Browse files
committed
PGPRO-10866: Use const decoration to avoid warnings:
"passing 'const char *' to parameter of type 'char *' discards qualifiers"[-Wincompatible-pointer-types-discards-qualifiers]And replace palloc0+strcpy with pstrdup. Caused by: - d5f139cb6814f0af2d2e1106899361e45c305630 (PostgreSQL) Constify fields and parameters in spell.cTags: shared_ispell
1 parent64ee638 commita11142e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

‎src/shared_ispell.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static SegmentInfo *segment_info = NULL;
8080
staticvoidispell_shmem_startup(void);
8181

8282
staticchar*shalloc(intbytes);
83-
staticchar*shstrcpy(char*str);
83+
staticchar*shstrcpy(constchar*str);
8484

8585
staticSharedIspellDict*copyIspellDict(IspellDict*dict,char*dictFile,char*affixFile,intbytes,intwords);
8686
staticSharedStopList*copyStopList(StopList*list,char*stopFile,intbytes);
@@ -346,13 +346,10 @@ init_shared_dict(DictInfo *info, MemoryContext infoCntx,
346346
dict->useFlagAliases= true;
347347
dict->lenAffixData=info->dict.lenAffixData;
348348
dict->nAffixData=info->dict.nAffixData;
349-
dict->AffixData= (char**)palloc0(dict->nAffixData*sizeof(char*));
349+
dict->AffixData= (constchar**)palloc0(dict->nAffixData*sizeof(char*));
350350

351351
for (i=0;i<dict->nAffixData;i++)
352-
{
353-
dict->AffixData[i]=palloc0(strlen(info->dict.AffixData[i])+1);
354-
strcpy(dict->AffixData[i],info->dict.AffixData[i]);
355-
}
352+
dict->AffixData[i]=pstrdup(info->dict.AffixData[i]);
356353
}
357354

358355
NISortDictionary(dict);
@@ -709,7 +706,7 @@ shalloc(int bytes)
709706
* by the code that reads and parses the dictionary / affixes).
710707
*/
711708
staticchar*
712-
shstrcpy(char*str)
709+
shstrcpy(constchar*str)
713710
{
714711
char*tmp=shalloc(strlen(str)+1);
715712

@@ -821,7 +818,7 @@ copyIspellDict(IspellDict *dict, char *dictFile, char *affixFile, int size, int
821818

822819
/* copy affix data */
823820
copy->dict.nAffixData=dict->nAffixData;
824-
copy->dict.AffixData= (char**)shalloc(sizeof(char*)*dict->nAffixData);
821+
copy->dict.AffixData= (constchar**)shalloc(sizeof(char*)*dict->nAffixData);
825822
for (i=0;i<copy->dict.nAffixData;i++)
826823
copy->dict.AffixData[i]=shstrcpy(dict->AffixData[i]);
827824

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp