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

Commit86f5fcf

Browse files
committed
Fix failure when uniq-ifying an array of zero elements.
Teodor Sigaev
1 parentf9b232f commit86f5fcf

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

‎contrib/intarray/_int.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,8 @@ internal_size(int *a, int len)
967967
returnsize;
968968
}
969969

970+
#defineUNIX_UNIQ(a) a = _int_unique(a)
971+
970972
/* r is sorted and size of r > 1 */
971973
staticArrayType*
972974
_int_unique(ArrayType*r)
@@ -976,6 +978,9 @@ _int_unique(ArrayType *r)
976978
*data;
977979
intnum=ARRNELEMS(r);
978980

981+
if (num<2 )
982+
returnr;
983+
979984
data=tmp=dr=ARRPTR(r);
980985
while (tmp-data<num)
981986
if (*tmp!=*dr)
@@ -2445,23 +2450,6 @@ if (ARRNELEMS(a) > 1)\
24452450
qsort((void*)ARRPTR(a), ARRNELEMS(a),sizeof(int4),\
24462451
(direction) ? compASC : compDESC )
24472452

2448-
#defineUNIX_UNIQ(a) a = resize_intArrayType(a, unix_uniq(ARRPTR(a), ARRNELEMS(a)))
2449-
2450-
staticint32
2451-
unix_uniq(int32*array,int32count)
2452-
{
2453-
registerint32i,
2454-
k=0;
2455-
2456-
for (i=1;i<count;i++)
2457-
if (array[k]!=array[i])
2458-
{
2459-
k++;
2460-
if (i>k)
2461-
array[k]=array[i];
2462-
}
2463-
return (k+1);
2464-
}
24652453

24662454
Datum
24672455
intset(PG_FUNCTION_ARGS)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp