static int InitPriorityQ( TESStesselator *tess ) /* * Insert all vertices into the priority queue which determines the * order in which vertices cross the sweep line. */ { PriorityQ *pq; TESSvertex *v, *vHead; int vertexCount = 0; vHead = &tess->mesh->vHead; for( v = vHead->next; v != vHead; v = v->next ) { vertexCount++; } /* Make sure there is enough space for sentinels. */ vertexCount += MAX( 8, tess->alloc.extraVertices ); pq = tess->pq = pqNewPriorityQ( &tess->alloc, vertexCount, (int (*)(PQkey, PQkey)) tesvertLeq ); if (pq == NULL) return 0; vHead = &tess->mesh->vHead; for( v = vHead->next; v != vHead; v = v->next ) { v->pqHandle = pqInsert( &tess->alloc, pq, v ); if (v->pqHandle == INV_HANDLE) break; } if (v != vHead || !pqInit( &tess->alloc, pq ) ) { pqDeletePriorityQ( &tess->alloc, tess->pq ); tess->pq = NULL; return 0; } return 1; }
static int InitPriorityQ( GLUtesselator *tess ) /* * Insert all vertices into the priority queue which determines the * order in which vertices cross the sweep line. */ { PriorityQ *pq; GLUvertex *v, *vHead; /* __gl_pqSortNewPriorityQ */ pq = tess->pq = pqNewPriorityQ( (int (*)(PQkey, PQkey)) __gl_vertLeq ); if (pq == NULL) return 0; vHead = &tess->mesh->vHead; for( v = vHead->next; v != vHead; v = v->next ) { v->pqHandle = pqInsert( pq, v ); /* __gl_pqSortInsert */ if (v->pqHandle == LONG_MAX) break; } if (v != vHead || !pqInit( pq ) ) { /* __gl_pqSortInit */ pqDeletePriorityQ(tess->pq); /* __gl_pqSortDeletePriorityQ */ tess->pq = NULL; return 0; } return 1; }