1
0
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:
Tom Lane
2006-10-05 17:57:40 +00:00
parent f2332ea1e9
commit e378f82e00
6 changed files with 77 additions and 88 deletions

View File

@@ -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)
{