Fossil SCM

Change the "pqueue_" prefix on methods of the priority queue object to be "pqueuex_" to avoid conflicts with OpenSSL.

drh 2012-06-12 11:20 trunk
Commit 81162c716c07678d757ec7f756311c0f3218afd2
3 files changed +10 -10 +11 -7 +5 -5
+10 -10
--- src/descendants.c
+++ src/descendants.c
@@ -162,34 +162,34 @@
162162
Bag seen;
163163
PQueue queue;
164164
Stmt ins;
165165
Stmt q;
166166
bag_init(&seen);
167
- pqueue_init(&queue);
167
+ pqueuex_init(&queue);
168168
bag_insert(&seen, rid);
169
- pqueue_insert(&queue, rid, 0.0, 0);
169
+ pqueuex_insert(&queue, rid, 0.0, 0);
170170
db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
171171
db_prepare(&q,
172172
"SELECT a.pid, b.mtime FROM plink a LEFT JOIN plink b ON b.cid=a.pid"
173173
" WHERE a.cid=:rid"
174174
);
175
- while( (N--)>0 && (rid = pqueue_extract(&queue, 0))!=0 ){
175
+ while( (N--)>0 && (rid = pqueuex_extract(&queue, 0))!=0 ){
176176
db_bind_int(&ins, ":rid", rid);
177177
db_step(&ins);
178178
db_reset(&ins);
179179
db_bind_int(&q, ":rid", rid);
180180
while( db_step(&q)==SQLITE_ROW ){
181181
int pid = db_column_int(&q, 0);
182182
double mtime = db_column_double(&q, 1);
183183
if( bag_insert(&seen, pid) ){
184
- pqueue_insert(&queue, pid, -mtime, 0);
184
+ pqueuex_insert(&queue, pid, -mtime, 0);
185185
}
186186
}
187187
db_reset(&q);
188188
}
189189
bag_clear(&seen);
190
- pqueue_clear(&queue);
190
+ pqueuex_clear(&queue);
191191
db_finalize(&ins);
192192
db_finalize(&q);
193193
}
194194
195195
/*
@@ -237,31 +237,31 @@
237237
PQueue queue;
238238
Stmt ins;
239239
Stmt q;
240240
241241
bag_init(&seen);
242
- pqueue_init(&queue);
242
+ pqueuex_init(&queue);
243243
bag_insert(&seen, rid);
244
- pqueue_insert(&queue, rid, 0.0, 0);
244
+ pqueuex_insert(&queue, rid, 0.0, 0);
245245
db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
246246
db_prepare(&q, "SELECT cid, mtime FROM plink WHERE pid=:rid");
247
- while( (N--)>0 && (rid = pqueue_extract(&queue, 0))!=0 ){
247
+ while( (N--)>0 && (rid = pqueuex_extract(&queue, 0))!=0 ){
248248
db_bind_int(&ins, ":rid", rid);
249249
db_step(&ins);
250250
db_reset(&ins);
251251
db_bind_int(&q, ":rid", rid);
252252
while( db_step(&q)==SQLITE_ROW ){
253253
int pid = db_column_int(&q, 0);
254254
double mtime = db_column_double(&q, 1);
255255
if( bag_insert(&seen, pid) ){
256
- pqueue_insert(&queue, pid, mtime, 0);
256
+ pqueuex_insert(&queue, pid, mtime, 0);
257257
}
258258
}
259259
db_reset(&q);
260260
}
261261
bag_clear(&seen);
262
- pqueue_clear(&queue);
262
+ pqueuex_clear(&queue);
263263
db_finalize(&ins);
264264
db_finalize(&q);
265265
}
266266
267267
/*
268268
--- src/descendants.c
+++ src/descendants.c
@@ -162,34 +162,34 @@
162 Bag seen;
163 PQueue queue;
164 Stmt ins;
165 Stmt q;
166 bag_init(&seen);
167 pqueue_init(&queue);
168 bag_insert(&seen, rid);
169 pqueue_insert(&queue, rid, 0.0, 0);
170 db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
171 db_prepare(&q,
172 "SELECT a.pid, b.mtime FROM plink a LEFT JOIN plink b ON b.cid=a.pid"
173 " WHERE a.cid=:rid"
174 );
175 while( (N--)>0 && (rid = pqueue_extract(&queue, 0))!=0 ){
176 db_bind_int(&ins, ":rid", rid);
177 db_step(&ins);
178 db_reset(&ins);
179 db_bind_int(&q, ":rid", rid);
180 while( db_step(&q)==SQLITE_ROW ){
181 int pid = db_column_int(&q, 0);
182 double mtime = db_column_double(&q, 1);
183 if( bag_insert(&seen, pid) ){
184 pqueue_insert(&queue, pid, -mtime, 0);
185 }
186 }
187 db_reset(&q);
188 }
189 bag_clear(&seen);
190 pqueue_clear(&queue);
191 db_finalize(&ins);
192 db_finalize(&q);
193 }
194
195 /*
@@ -237,31 +237,31 @@
237 PQueue queue;
238 Stmt ins;
239 Stmt q;
240
241 bag_init(&seen);
242 pqueue_init(&queue);
243 bag_insert(&seen, rid);
244 pqueue_insert(&queue, rid, 0.0, 0);
245 db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
246 db_prepare(&q, "SELECT cid, mtime FROM plink WHERE pid=:rid");
247 while( (N--)>0 && (rid = pqueue_extract(&queue, 0))!=0 ){
248 db_bind_int(&ins, ":rid", rid);
249 db_step(&ins);
250 db_reset(&ins);
251 db_bind_int(&q, ":rid", rid);
252 while( db_step(&q)==SQLITE_ROW ){
253 int pid = db_column_int(&q, 0);
254 double mtime = db_column_double(&q, 1);
255 if( bag_insert(&seen, pid) ){
256 pqueue_insert(&queue, pid, mtime, 0);
257 }
258 }
259 db_reset(&q);
260 }
261 bag_clear(&seen);
262 pqueue_clear(&queue);
263 db_finalize(&ins);
264 db_finalize(&q);
265 }
266
267 /*
268
--- src/descendants.c
+++ src/descendants.c
@@ -162,34 +162,34 @@
162 Bag seen;
163 PQueue queue;
164 Stmt ins;
165 Stmt q;
166 bag_init(&seen);
167 pqueuex_init(&queue);
168 bag_insert(&seen, rid);
169 pqueuex_insert(&queue, rid, 0.0, 0);
170 db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
171 db_prepare(&q,
172 "SELECT a.pid, b.mtime FROM plink a LEFT JOIN plink b ON b.cid=a.pid"
173 " WHERE a.cid=:rid"
174 );
175 while( (N--)>0 && (rid = pqueuex_extract(&queue, 0))!=0 ){
176 db_bind_int(&ins, ":rid", rid);
177 db_step(&ins);
178 db_reset(&ins);
179 db_bind_int(&q, ":rid", rid);
180 while( db_step(&q)==SQLITE_ROW ){
181 int pid = db_column_int(&q, 0);
182 double mtime = db_column_double(&q, 1);
183 if( bag_insert(&seen, pid) ){
184 pqueuex_insert(&queue, pid, -mtime, 0);
185 }
186 }
187 db_reset(&q);
188 }
189 bag_clear(&seen);
190 pqueuex_clear(&queue);
191 db_finalize(&ins);
192 db_finalize(&q);
193 }
194
195 /*
@@ -237,31 +237,31 @@
237 PQueue queue;
238 Stmt ins;
239 Stmt q;
240
241 bag_init(&seen);
242 pqueuex_init(&queue);
243 bag_insert(&seen, rid);
244 pqueuex_insert(&queue, rid, 0.0, 0);
245 db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
246 db_prepare(&q, "SELECT cid, mtime FROM plink WHERE pid=:rid");
247 while( (N--)>0 && (rid = pqueuex_extract(&queue, 0))!=0 ){
248 db_bind_int(&ins, ":rid", rid);
249 db_step(&ins);
250 db_reset(&ins);
251 db_bind_int(&q, ":rid", rid);
252 while( db_step(&q)==SQLITE_ROW ){
253 int pid = db_column_int(&q, 0);
254 double mtime = db_column_double(&q, 1);
255 if( bag_insert(&seen, pid) ){
256 pqueuex_insert(&queue, pid, mtime, 0);
257 }
258 }
259 db_reset(&q);
260 }
261 bag_clear(&seen);
262 pqueuex_clear(&queue);
263 db_finalize(&ins);
264 db_finalize(&q);
265 }
266
267 /*
268
+11 -7
--- src/pqueue.c
+++ src/pqueue.c
@@ -22,10 +22,14 @@
2222
**
2323
** The way this queue is used, we never expect it to contain more
2424
** than 2 or 3 elements, so a simple array is sufficient as the
2525
** implementation. This could give worst case O(N) insert times,
2626
** but because of the nature of the problem we expect O(1) performance.
27
+**
28
+** Compatibility note: Some versions of OpenSSL export a symbols
29
+** like "pqueue_insert". This is, technically, a bug in OpenSSL.
30
+** We work around it here by using "pqueuex_" instead of "pqueue_".
2731
*/
2832
#include "config.h"
2933
#include "pqueue.h"
3034
#include <assert.h>
3135
@@ -47,37 +51,37 @@
4751
#endif
4852
4953
/*
5054
** Initialize a PQueue structure
5155
*/
52
-void pqueue_init(PQueue *p){
56
+void pqueuex_init(PQueue *p){
5357
memset(p, 0, sizeof(*p));
5458
}
5559
5660
/*
5761
** Destroy a PQueue. Delete all of its content.
5862
*/
59
-void pqueue_clear(PQueue *p){
63
+void pqueuex_clear(PQueue *p){
6064
free(p->a);
61
- pqueue_init(p);
65
+ pqueuex_init(p);
6266
}
6367
6468
/*
6569
** Change the size of the queue so that it contains N slots
6670
*/
67
-static void pqueue_resize(PQueue *p, int N){
71
+static void pqueuex_resize(PQueue *p, int N){
6872
p->a = fossil_realloc(p->a, sizeof(p->a[0])*N);
6973
p->sz = N;
7074
}
7175
7276
/*
7377
** Insert element e into the queue.
7478
*/
75
-void pqueue_insert(PQueue *p, int e, double v, void *pData){
79
+void pqueuex_insert(PQueue *p, int e, double v, void *pData){
7680
int i, j;
7781
if( p->cnt+1>p->sz ){
78
- pqueue_resize(p, p->cnt+5);
82
+ pqueuex_resize(p, p->cnt+5);
7983
}
8084
for(i=0; i<p->cnt; i++){
8185
if( p->a[i].value>v ){
8286
for(j=p->cnt; j>i; j--){
8387
p->a[j] = p->a[j-1];
@@ -94,11 +98,11 @@
9498
/*
9599
** Extract the first element from the queue (the element with
96100
** the smallest value) and return its ID. Return 0 if the queue
97101
** is empty.
98102
*/
99
-int pqueue_extract(PQueue *p, void **pp){
103
+int pqueuex_extract(PQueue *p, void **pp){
100104
int e, i;
101105
if( p->cnt==0 ){
102106
if( pp ) *pp = 0;
103107
return 0;
104108
}
105109
--- src/pqueue.c
+++ src/pqueue.c
@@ -22,10 +22,14 @@
22 **
23 ** The way this queue is used, we never expect it to contain more
24 ** than 2 or 3 elements, so a simple array is sufficient as the
25 ** implementation. This could give worst case O(N) insert times,
26 ** but because of the nature of the problem we expect O(1) performance.
 
 
 
 
27 */
28 #include "config.h"
29 #include "pqueue.h"
30 #include <assert.h>
31
@@ -47,37 +51,37 @@
47 #endif
48
49 /*
50 ** Initialize a PQueue structure
51 */
52 void pqueue_init(PQueue *p){
53 memset(p, 0, sizeof(*p));
54 }
55
56 /*
57 ** Destroy a PQueue. Delete all of its content.
58 */
59 void pqueue_clear(PQueue *p){
60 free(p->a);
61 pqueue_init(p);
62 }
63
64 /*
65 ** Change the size of the queue so that it contains N slots
66 */
67 static void pqueue_resize(PQueue *p, int N){
68 p->a = fossil_realloc(p->a, sizeof(p->a[0])*N);
69 p->sz = N;
70 }
71
72 /*
73 ** Insert element e into the queue.
74 */
75 void pqueue_insert(PQueue *p, int e, double v, void *pData){
76 int i, j;
77 if( p->cnt+1>p->sz ){
78 pqueue_resize(p, p->cnt+5);
79 }
80 for(i=0; i<p->cnt; i++){
81 if( p->a[i].value>v ){
82 for(j=p->cnt; j>i; j--){
83 p->a[j] = p->a[j-1];
@@ -94,11 +98,11 @@
94 /*
95 ** Extract the first element from the queue (the element with
96 ** the smallest value) and return its ID. Return 0 if the queue
97 ** is empty.
98 */
99 int pqueue_extract(PQueue *p, void **pp){
100 int e, i;
101 if( p->cnt==0 ){
102 if( pp ) *pp = 0;
103 return 0;
104 }
105
--- src/pqueue.c
+++ src/pqueue.c
@@ -22,10 +22,14 @@
22 **
23 ** The way this queue is used, we never expect it to contain more
24 ** than 2 or 3 elements, so a simple array is sufficient as the
25 ** implementation. This could give worst case O(N) insert times,
26 ** but because of the nature of the problem we expect O(1) performance.
27 **
28 ** Compatibility note: Some versions of OpenSSL export a symbols
29 ** like "pqueue_insert". This is, technically, a bug in OpenSSL.
30 ** We work around it here by using "pqueuex_" instead of "pqueue_".
31 */
32 #include "config.h"
33 #include "pqueue.h"
34 #include <assert.h>
35
@@ -47,37 +51,37 @@
51 #endif
52
53 /*
54 ** Initialize a PQueue structure
55 */
56 void pqueuex_init(PQueue *p){
57 memset(p, 0, sizeof(*p));
58 }
59
60 /*
61 ** Destroy a PQueue. Delete all of its content.
62 */
63 void pqueuex_clear(PQueue *p){
64 free(p->a);
65 pqueuex_init(p);
66 }
67
68 /*
69 ** Change the size of the queue so that it contains N slots
70 */
71 static void pqueuex_resize(PQueue *p, int N){
72 p->a = fossil_realloc(p->a, sizeof(p->a[0])*N);
73 p->sz = N;
74 }
75
76 /*
77 ** Insert element e into the queue.
78 */
79 void pqueuex_insert(PQueue *p, int e, double v, void *pData){
80 int i, j;
81 if( p->cnt+1>p->sz ){
82 pqueuex_resize(p, p->cnt+5);
83 }
84 for(i=0; i<p->cnt; i++){
85 if( p->a[i].value>v ){
86 for(j=p->cnt; j>i; j--){
87 p->a[j] = p->a[j-1];
@@ -94,11 +98,11 @@
98 /*
99 ** Extract the first element from the queue (the element with
100 ** the smallest value) and return its ID. Return 0 if the queue
101 ** is empty.
102 */
103 int pqueuex_extract(PQueue *p, void **pp){
104 int e, i;
105 if( p->cnt==0 ){
106 if( pp ) *pp = 0;
107 return 0;
108 }
109
+5 -5
--- src/tag.c
+++ src/tag.c
@@ -43,12 +43,12 @@
4343
Stmt s; /* Query the children of :pid to which to propagate */
4444
Stmt ins; /* INSERT INTO tagxref */
4545
Stmt eventupdate; /* UPDATE event */
4646
4747
assert( tagType==0 || tagType==2 );
48
- pqueue_init(&queue);
49
- pqueue_insert(&queue, pid, 0.0, 0);
48
+ pqueuex_init(&queue);
49
+ pqueuex_insert(&queue, pid, 0.0, 0);
5050
5151
/* Query for children of :pid to which to propagate the tag.
5252
** Three returns: (1) rid of the child. (2) timestamp of child.
5353
** (3) True to propagate or false to block.
5454
*/
@@ -79,18 +79,18 @@
7979
if( tagid==TAG_BGCOLOR ){
8080
db_prepare(&eventupdate,
8181
"UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue
8282
);
8383
}
84
- while( (pid = pqueue_extract(&queue, 0))!=0 ){
84
+ while( (pid = pqueuex_extract(&queue, 0))!=0 ){
8585
db_bind_int(&s, ":pid", pid);
8686
while( db_step(&s)==SQLITE_ROW ){
8787
int doit = db_column_int(&s, 2);
8888
if( doit ){
8989
int cid = db_column_int(&s, 0);
9090
double mtime = db_column_double(&s, 1);
91
- pqueue_insert(&queue, cid, mtime, 0);
91
+ pqueuex_insert(&queue, cid, mtime, 0);
9292
db_bind_int(&ins, ":rid", cid);
9393
db_step(&ins);
9494
db_reset(&ins);
9595
if( tagid==TAG_BGCOLOR ){
9696
db_bind_int(&eventupdate, ":rid", cid);
@@ -102,11 +102,11 @@
102102
}
103103
}
104104
}
105105
db_reset(&s);
106106
}
107
- pqueue_clear(&queue);
107
+ pqueuex_clear(&queue);
108108
db_finalize(&ins);
109109
db_finalize(&s);
110110
if( tagid==TAG_BGCOLOR ){
111111
db_finalize(&eventupdate);
112112
}
113113
--- src/tag.c
+++ src/tag.c
@@ -43,12 +43,12 @@
43 Stmt s; /* Query the children of :pid to which to propagate */
44 Stmt ins; /* INSERT INTO tagxref */
45 Stmt eventupdate; /* UPDATE event */
46
47 assert( tagType==0 || tagType==2 );
48 pqueue_init(&queue);
49 pqueue_insert(&queue, pid, 0.0, 0);
50
51 /* Query for children of :pid to which to propagate the tag.
52 ** Three returns: (1) rid of the child. (2) timestamp of child.
53 ** (3) True to propagate or false to block.
54 */
@@ -79,18 +79,18 @@
79 if( tagid==TAG_BGCOLOR ){
80 db_prepare(&eventupdate,
81 "UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue
82 );
83 }
84 while( (pid = pqueue_extract(&queue, 0))!=0 ){
85 db_bind_int(&s, ":pid", pid);
86 while( db_step(&s)==SQLITE_ROW ){
87 int doit = db_column_int(&s, 2);
88 if( doit ){
89 int cid = db_column_int(&s, 0);
90 double mtime = db_column_double(&s, 1);
91 pqueue_insert(&queue, cid, mtime, 0);
92 db_bind_int(&ins, ":rid", cid);
93 db_step(&ins);
94 db_reset(&ins);
95 if( tagid==TAG_BGCOLOR ){
96 db_bind_int(&eventupdate, ":rid", cid);
@@ -102,11 +102,11 @@
102 }
103 }
104 }
105 db_reset(&s);
106 }
107 pqueue_clear(&queue);
108 db_finalize(&ins);
109 db_finalize(&s);
110 if( tagid==TAG_BGCOLOR ){
111 db_finalize(&eventupdate);
112 }
113
--- src/tag.c
+++ src/tag.c
@@ -43,12 +43,12 @@
43 Stmt s; /* Query the children of :pid to which to propagate */
44 Stmt ins; /* INSERT INTO tagxref */
45 Stmt eventupdate; /* UPDATE event */
46
47 assert( tagType==0 || tagType==2 );
48 pqueuex_init(&queue);
49 pqueuex_insert(&queue, pid, 0.0, 0);
50
51 /* Query for children of :pid to which to propagate the tag.
52 ** Three returns: (1) rid of the child. (2) timestamp of child.
53 ** (3) True to propagate or false to block.
54 */
@@ -79,18 +79,18 @@
79 if( tagid==TAG_BGCOLOR ){
80 db_prepare(&eventupdate,
81 "UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue
82 );
83 }
84 while( (pid = pqueuex_extract(&queue, 0))!=0 ){
85 db_bind_int(&s, ":pid", pid);
86 while( db_step(&s)==SQLITE_ROW ){
87 int doit = db_column_int(&s, 2);
88 if( doit ){
89 int cid = db_column_int(&s, 0);
90 double mtime = db_column_double(&s, 1);
91 pqueuex_insert(&queue, cid, mtime, 0);
92 db_bind_int(&ins, ":rid", cid);
93 db_step(&ins);
94 db_reset(&ins);
95 if( tagid==TAG_BGCOLOR ){
96 db_bind_int(&eventupdate, ":rid", cid);
@@ -102,11 +102,11 @@
102 }
103 }
104 }
105 db_reset(&s);
106 }
107 pqueuex_clear(&queue);
108 db_finalize(&ins);
109 db_finalize(&s);
110 if( tagid==TAG_BGCOLOR ){
111 db_finalize(&eventupdate);
112 }
113

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button