@@ -94,7 +94,7 @@ static int sizeStopList(StopList *list, char *stopFile);
94
94
static Size
95
95
max_ispell_mem_size ()
96
96
{
97
- return (Size )max_ispell_mem_size_kb * 1024L ;
97
+ return (Size ) max_ispell_mem_size_kb * 1024L ;
98
98
}
99
99
100
100
/*
@@ -134,11 +134,11 @@ _PG_init(void)
134
134
*/
135
135
RequestAddinShmemSpace (max_ispell_mem_size ());
136
136
137
- #if PG_VERSION_NUM >= 90600
137
+ #if PG_VERSION_NUM >= 90600
138
138
RequestNamedLWLockTranche ("shared_ispell" , 1 );
139
- #else
139
+ #else
140
140
RequestAddinLWLocks (1 );
141
- #endif
141
+ #endif
142
142
143
143
/* Install hooks. */
144
144
prev_shmem_startup_hook = shmem_startup_hook ;
@@ -166,8 +166,8 @@ _PG_fini(void)
166
166
static void
167
167
ispell_shmem_startup ()
168
168
{
169
- bool found = false;
170
- char * segment ;
169
+ bool found = false;
170
+ char * segment ;
171
171
172
172
if (prev_shmem_startup_hook )
173
173
prev_shmem_startup_hook ();
@@ -191,8 +191,8 @@ ispell_shmem_startup()
191
191
segment_info -> lock = LWLockAssign ();
192
192
#endif
193
193
segment_info -> firstfree = segment + MAXALIGN (sizeof (SegmentInfo ));
194
- segment_info -> available = max_ispell_mem_size ()
195
- - (int )(segment_info -> firstfree - segment );
194
+ segment_info -> available = max_ispell_mem_size () -
195
+ (int ) (segment_info -> firstfree - segment );
196
196
197
197
segment_info -> lastReset = GetCurrentTimestamp ();
198
198
}
@@ -311,7 +311,7 @@ init_shared_dict(DictInfo *info, MemoryContext infoCntx,
311
311
/* load the dictionary (word list) if not yet defined */
312
312
if (shdict == NULL )
313
313
{
314
- IspellDict * dict ;
314
+ IspellDict * dict ;
315
315
316
316
dict = (IspellDict * ) palloc0 (sizeof (IspellDict ));
317
317
@@ -422,14 +422,6 @@ init_shared_dict(DictInfo *info, MemoryContext infoCntx,
422
422
info -> infoCntx = infoCntx ;
423
423
}
424
424
425
- Datum dispell_init (PG_FUNCTION_ARGS );
426
- Datum dispell_lexize (PG_FUNCTION_ARGS );
427
- Datum dispell_reset (PG_FUNCTION_ARGS );
428
- Datum dispell_mem_available (PG_FUNCTION_ARGS );
429
- Datum dispell_mem_used (PG_FUNCTION_ARGS );
430
- Datum dispell_list_dicts (PG_FUNCTION_ARGS );
431
- Datum dispell_list_stoplists (PG_FUNCTION_ARGS );
432
-
433
425
PG_FUNCTION_INFO_V1 (dispell_init );
434
426
PG_FUNCTION_INFO_V1 (dispell_lexize );
435
427
PG_FUNCTION_INFO_V1 (dispell_reset );
@@ -453,7 +445,8 @@ dispell_reset(PG_FUNCTION_ARGS)
453
445
segment_info -> shstop = NULL ;
454
446
segment_info -> lastReset = GetCurrentTimestamp ();
455
447
segment_info -> firstfree = ((char * ) segment_info ) + MAXALIGN (sizeof (SegmentInfo ));
456
- segment_info -> available = max_ispell_mem_size () - (int )(segment_info -> firstfree - (char * ) segment_info );
448
+ segment_info -> available = max_ispell_mem_size () -
449
+ (int ) (segment_info -> firstfree - (char * ) segment_info );
457
450
458
451
memset (segment_info -> firstfree , 0 , segment_info -> available );
459
452
@@ -479,12 +472,14 @@ dispell_mem_available(PG_FUNCTION_ARGS)
479
472
}
480
473
481
474
/*
482
- * Returns amount of 'occupied space' in the shared segment (used by current dictionaries).
475
+ * Returns amount of 'occupied space' in the shared segment (used by current
476
+ * dictionaries).
483
477
*/
484
478
Datum
485
479
dispell_mem_used (PG_FUNCTION_ARGS )
486
480
{
487
- int result = 0 ;
481
+ int result = 0 ;
482
+
488
483
LWLockAcquire (segment_info -> lock , LW_SHARED );
489
484
490
485
result = max_ispell_mem_size () - segment_info -> available ;
@@ -679,7 +674,8 @@ dispell_lexize(PG_FUNCTION_ARGS)
679
674
static char *
680
675
shalloc (int bytes )
681
676
{
682
- char * result ;
677
+ char * result ;
678
+
683
679
bytes = MAXALIGN (bytes );
684
680
685
681
/* This shouldn't really happen, as the init_shared_dict checks the size
@@ -706,8 +702,10 @@ shalloc(int bytes)
706
702
static char *
707
703
shstrcpy (char * str )
708
704
{
709
- char * tmp = shalloc (strlen (str ) + 1 );
705
+ char * tmp = shalloc (strlen (str ) + 1 );
706
+
710
707
memcpy (tmp , str , strlen (str ) + 1 );
708
+
711
709
return tmp ;
712
710
}
713
711
@@ -801,8 +799,7 @@ sizeStopList(StopList *list, char *stopFile)
801
799
static SharedIspellDict *
802
800
copyIspellDict (IspellDict * dict , char * dictFile , char * affixFile , int size , int words )
803
801
{
804
- int i ;
805
-
802
+ int i ;
806
803
SharedIspellDict * copy = (SharedIspellDict * ) shalloc (sizeof (SharedIspellDict ));
807
804
808
805
copy -> dictFile = shalloc (strlen (dictFile ) + 1 );
@@ -834,8 +831,8 @@ copyIspellDict(IspellDict *dict, char *dictFile, char *affixFile, int size, int
834
831
static int
835
832
sizeIspellDict (IspellDict * dict , char * dictFile , char * affixFile )
836
833
{
837
- int i ;
838
- int size = MAXALIGN (sizeof (SharedIspellDict ));
834
+ int i ;
835
+ int size = MAXALIGN (sizeof (SharedIspellDict ));
839
836
840
837
size += MAXALIGN (strlen (dictFile ) + 1 );
841
838
size += MAXALIGN (strlen (affixFile ) + 1 );
0 commit comments