mirror of
https://github.com/postgres/postgres.git
synced 2025-08-06 18:42:54 +03:00
Make use of qsort_arg in several places that were formerly using klugy
static variables. This avoids any risk of potential non-reentrancy, and in particular offers a much cleaner workaround for the Intel compiler bug that was affecting ginutil.c.
This commit is contained in:
@@ -85,14 +85,14 @@ uniquePos(WordEntryPos * a, int4 l)
|
||||
return res + 1 - a;
|
||||
}
|
||||
|
||||
static char *BufferStr;
|
||||
static int
|
||||
compareentry(const void *a, const void *b)
|
||||
compareentry(const void *a, const void *b, void *arg)
|
||||
{
|
||||
char *BufferStr = (char *) arg;
|
||||
|
||||
if (((WordEntryIN *) a)->entry.len == ((WordEntryIN *) b)->entry.len)
|
||||
{
|
||||
return strncmp(
|
||||
&BufferStr[((WordEntryIN *) a)->entry.pos],
|
||||
return strncmp(&BufferStr[((WordEntryIN *) a)->entry.pos],
|
||||
&BufferStr[((WordEntryIN *) b)->entry.pos],
|
||||
((WordEntryIN *) a)->entry.len);
|
||||
}
|
||||
@@ -117,8 +117,7 @@ uniqueentry(WordEntryIN * a, int4 l, char *buf, int4 *outbuflen)
|
||||
}
|
||||
|
||||
ptr = a + 1;
|
||||
BufferStr = buf;
|
||||
qsort((void *) a, l, sizeof(WordEntryIN), compareentry);
|
||||
qsort_arg((void *) a, l, sizeof(WordEntryIN), compareentry, (void *) buf);
|
||||
|
||||
while (ptr - a < l)
|
||||
{
|
||||
|
Reference in New Issue
Block a user