Fossil SCM
Fixed a memory leak in tagview_page_list_tags(). Minor other refactorings.
Commit
2cb3290e6767e51d190f746abbac4f330ae14517
Parent
b81e93f576cbddf…
1 file changed
+17
-8
+17
-8
| --- src/tagview.c | ||
| +++ src/tagview.c | ||
| @@ -26,10 +26,18 @@ | ||
| 26 | 26 | ** Implementation of the Tag View page |
| 27 | 27 | */ |
| 28 | 28 | #include <assert.h> |
| 29 | 29 | #include "config.h" |
| 30 | 30 | #include "tagview.h" |
| 31 | + | |
| 32 | + | |
| 33 | +#if 1 | |
| 34 | +# define TAGVIEW_DEFAULT_FILTER "AND t.tagname NOT GLOB 'wiki-*' " | |
| 35 | +#else | |
| 36 | +# define TAGVIEW_DEFAULT_FILTER | |
| 37 | +#endif | |
| 38 | + | |
| 31 | 39 | |
| 32 | 40 | /** |
| 33 | 41 | tagview_strxform_f is a typedef for funcs with the following policy: |
| 34 | 42 | |
| 35 | 43 | They accept a const string which they then transform into some other |
| @@ -59,11 +67,11 @@ | ||
| 59 | 67 | { |
| 60 | 68 | const int offset = 10; |
| 61 | 69 | char shortname[offset+1]; |
| 62 | 70 | shortname[offset] = '\0'; |
| 63 | 71 | memcpy( shortname, uuid, offset ); |
| 64 | - return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>", | |
| 72 | + return mprintf( "<tt><a href='%s/vinfo/%s'><span style='font-size:1.5em'>%s</span>%s</a></tt>", | |
| 65 | 73 | g.zBaseURL, uuid, shortname, uuid+offset ); |
| 66 | 74 | } |
| 67 | 75 | |
| 68 | 76 | /** Returns a hyperlink to the given tag. */ |
| 69 | 77 | static char * tagview_xf_link_to_tagid( char const * tagid ) |
| @@ -186,24 +194,24 @@ | ||
| 186 | 194 | @ <h2>Tags matching [%s(likeclause)]:</h2> |
| 187 | 195 | } |
| 188 | 196 | else |
| 189 | 197 | { |
| 190 | 198 | limitstr = mprintf( "LIMIT %d", limit ); |
| 191 | - @ <h2>%d(limit) most recent non-wiki tags:</h2> | |
| 199 | + @ <h2>%d(limit) most recent tags:</h2> | |
| 192 | 200 | } |
| 193 | 201 | char * sql = mprintf( |
| 194 | 202 | "SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid " |
| 195 | 203 | "FROM tag t, tagxref tx, blob b " |
| 196 | 204 | "WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) " |
| 197 | 205 | "AND (tx.tagtype != 0) %s " |
| 198 | - "AND t.tagname NOT GLOB 'wiki-*' " | |
| 206 | + TAGVIEW_DEFAULT_FILTER | |
| 199 | 207 | "ORDER BY tx.mtime DESC %s", |
| 200 | 208 | likeclause ? likeclause : " ", |
| 201 | 209 | limitstr ? limitstr : " " |
| 202 | 210 | ); |
| 203 | - /* " AND t.tagname NOT GLOB 'wiki-*'" // Do we want this?? */ | |
| 204 | - | |
| 211 | + if( limitstr ) free(limitstr); | |
| 212 | + if( likeclause ) free(likeclause); | |
| 205 | 213 | char const * const colnames[] = { |
| 206 | 214 | "Tag ID", "Name", "Timestamp", "Version" |
| 207 | 215 | }; |
| 208 | 216 | tagview_strxform_f xf[] = { |
| 209 | 217 | tagview_xf_link_to_tagid, |
| @@ -244,11 +252,11 @@ | ||
| 244 | 252 | @ <h2>Tag #%d(tagid):</h2> |
| 245 | 253 | char * sql = mprintf( |
| 246 | 254 | "SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid " |
| 247 | 255 | "FROM tag t, tagxref tx, blob b " |
| 248 | 256 | "WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) " |
| 249 | - "AND t.tagname NOT GLOB 'wiki-*' " | |
| 257 | + TAGVIEW_DEFAULT_FILTER | |
| 250 | 258 | "ORDER BY tx.mtime DESC", |
| 251 | 259 | tagid); |
| 252 | 260 | char const * const colnames[] = { |
| 253 | 261 | "Tag Name", "Timestamp", "Version" |
| 254 | 262 | }; |
| @@ -269,11 +277,11 @@ | ||
| 269 | 277 | @ <h2>Tag '%s(tagname)':</h2> |
| 270 | 278 | char * sql = mprintf( |
| 271 | 279 | "SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid " |
| 272 | 280 | "FROM tag t, tagxref tx, blob b " |
| 273 | 281 | "WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) " |
| 274 | - "AND t.tagname NOT GLOB 'wiki-*' " | |
| 282 | + TAGVIEW_DEFAULT_FILTER | |
| 275 | 283 | "ORDER BY tx.mtime DESC", |
| 276 | 284 | tagname); |
| 277 | 285 | char const * const colnames[] = { |
| 278 | 286 | "Tag ID", "Timestamp", "Version" |
| 279 | 287 | }; |
| @@ -289,11 +297,10 @@ | ||
| 289 | 297 | |
| 290 | 298 | /* |
| 291 | 299 | ** WEBPAGE: /tagview |
| 292 | 300 | */ |
| 293 | 301 | void tagview_page(void){ |
| 294 | - | |
| 295 | 302 | login_check_credentials(); |
| 296 | 303 | if( !g.okRdWiki ){ |
| 297 | 304 | login_needed(); |
| 298 | 305 | } |
| 299 | 306 | style_header("Tags"); |
| @@ -316,5 +323,7 @@ | ||
| 316 | 323 | { |
| 317 | 324 | tagview_page_default(); |
| 318 | 325 | } |
| 319 | 326 | style_footer(); |
| 320 | 327 | } |
| 328 | + | |
| 329 | +#undef TAGVIEW_DEFAULT_FILTER | |
| 321 | 330 |
| --- src/tagview.c | |
| +++ src/tagview.c | |
| @@ -26,10 +26,18 @@ | |
| 26 | ** Implementation of the Tag View page |
| 27 | */ |
| 28 | #include <assert.h> |
| 29 | #include "config.h" |
| 30 | #include "tagview.h" |
| 31 | |
| 32 | /** |
| 33 | tagview_strxform_f is a typedef for funcs with the following policy: |
| 34 | |
| 35 | They accept a const string which they then transform into some other |
| @@ -59,11 +67,11 @@ | |
| 59 | { |
| 60 | const int offset = 10; |
| 61 | char shortname[offset+1]; |
| 62 | shortname[offset] = '\0'; |
| 63 | memcpy( shortname, uuid, offset ); |
| 64 | return mprintf( "<tt><a href='%s/vinfo/%s'><strong>%s</strong>%s</a></tt>", |
| 65 | g.zBaseURL, uuid, shortname, uuid+offset ); |
| 66 | } |
| 67 | |
| 68 | /** Returns a hyperlink to the given tag. */ |
| 69 | static char * tagview_xf_link_to_tagid( char const * tagid ) |
| @@ -186,24 +194,24 @@ | |
| 186 | @ <h2>Tags matching [%s(likeclause)]:</h2> |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | limitstr = mprintf( "LIMIT %d", limit ); |
| 191 | @ <h2>%d(limit) most recent non-wiki tags:</h2> |
| 192 | } |
| 193 | char * sql = mprintf( |
| 194 | "SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid " |
| 195 | "FROM tag t, tagxref tx, blob b " |
| 196 | "WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) " |
| 197 | "AND (tx.tagtype != 0) %s " |
| 198 | "AND t.tagname NOT GLOB 'wiki-*' " |
| 199 | "ORDER BY tx.mtime DESC %s", |
| 200 | likeclause ? likeclause : " ", |
| 201 | limitstr ? limitstr : " " |
| 202 | ); |
| 203 | /* " AND t.tagname NOT GLOB 'wiki-*'" // Do we want this?? */ |
| 204 | |
| 205 | char const * const colnames[] = { |
| 206 | "Tag ID", "Name", "Timestamp", "Version" |
| 207 | }; |
| 208 | tagview_strxform_f xf[] = { |
| 209 | tagview_xf_link_to_tagid, |
| @@ -244,11 +252,11 @@ | |
| 244 | @ <h2>Tag #%d(tagid):</h2> |
| 245 | char * sql = mprintf( |
| 246 | "SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid " |
| 247 | "FROM tag t, tagxref tx, blob b " |
| 248 | "WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) " |
| 249 | "AND t.tagname NOT GLOB 'wiki-*' " |
| 250 | "ORDER BY tx.mtime DESC", |
| 251 | tagid); |
| 252 | char const * const colnames[] = { |
| 253 | "Tag Name", "Timestamp", "Version" |
| 254 | }; |
| @@ -269,11 +277,11 @@ | |
| 269 | @ <h2>Tag '%s(tagname)':</h2> |
| 270 | char * sql = mprintf( |
| 271 | "SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid " |
| 272 | "FROM tag t, tagxref tx, blob b " |
| 273 | "WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) " |
| 274 | "AND t.tagname NOT GLOB 'wiki-*' " |
| 275 | "ORDER BY tx.mtime DESC", |
| 276 | tagname); |
| 277 | char const * const colnames[] = { |
| 278 | "Tag ID", "Timestamp", "Version" |
| 279 | }; |
| @@ -289,11 +297,10 @@ | |
| 289 | |
| 290 | /* |
| 291 | ** WEBPAGE: /tagview |
| 292 | */ |
| 293 | void tagview_page(void){ |
| 294 | |
| 295 | login_check_credentials(); |
| 296 | if( !g.okRdWiki ){ |
| 297 | login_needed(); |
| 298 | } |
| 299 | style_header("Tags"); |
| @@ -316,5 +323,7 @@ | |
| 316 | { |
| 317 | tagview_page_default(); |
| 318 | } |
| 319 | style_footer(); |
| 320 | } |
| 321 |
| --- src/tagview.c | |
| +++ src/tagview.c | |
| @@ -26,10 +26,18 @@ | |
| 26 | ** Implementation of the Tag View page |
| 27 | */ |
| 28 | #include <assert.h> |
| 29 | #include "config.h" |
| 30 | #include "tagview.h" |
| 31 | |
| 32 | |
| 33 | #if 1 |
| 34 | # define TAGVIEW_DEFAULT_FILTER "AND t.tagname NOT GLOB 'wiki-*' " |
| 35 | #else |
| 36 | # define TAGVIEW_DEFAULT_FILTER |
| 37 | #endif |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | tagview_strxform_f is a typedef for funcs with the following policy: |
| 42 | |
| 43 | They accept a const string which they then transform into some other |
| @@ -59,11 +67,11 @@ | |
| 67 | { |
| 68 | const int offset = 10; |
| 69 | char shortname[offset+1]; |
| 70 | shortname[offset] = '\0'; |
| 71 | memcpy( shortname, uuid, offset ); |
| 72 | return mprintf( "<tt><a href='%s/vinfo/%s'><span style='font-size:1.5em'>%s</span>%s</a></tt>", |
| 73 | g.zBaseURL, uuid, shortname, uuid+offset ); |
| 74 | } |
| 75 | |
| 76 | /** Returns a hyperlink to the given tag. */ |
| 77 | static char * tagview_xf_link_to_tagid( char const * tagid ) |
| @@ -186,24 +194,24 @@ | |
| 194 | @ <h2>Tags matching [%s(likeclause)]:</h2> |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | limitstr = mprintf( "LIMIT %d", limit ); |
| 199 | @ <h2>%d(limit) most recent tags:</h2> |
| 200 | } |
| 201 | char * sql = mprintf( |
| 202 | "SELECT t.tagid, t.tagname, DATETIME(tx.mtime), b.uuid " |
| 203 | "FROM tag t, tagxref tx, blob b " |
| 204 | "WHERE (t.tagid=tx.tagid) and (tx.srcid=b.rid) " |
| 205 | "AND (tx.tagtype != 0) %s " |
| 206 | TAGVIEW_DEFAULT_FILTER |
| 207 | "ORDER BY tx.mtime DESC %s", |
| 208 | likeclause ? likeclause : " ", |
| 209 | limitstr ? limitstr : " " |
| 210 | ); |
| 211 | if( limitstr ) free(limitstr); |
| 212 | if( likeclause ) free(likeclause); |
| 213 | char const * const colnames[] = { |
| 214 | "Tag ID", "Name", "Timestamp", "Version" |
| 215 | }; |
| 216 | tagview_strxform_f xf[] = { |
| 217 | tagview_xf_link_to_tagid, |
| @@ -244,11 +252,11 @@ | |
| 252 | @ <h2>Tag #%d(tagid):</h2> |
| 253 | char * sql = mprintf( |
| 254 | "SELECT DISTINCT (t.tagname), DATETIME(tx.mtime), b.uuid " |
| 255 | "FROM tag t, tagxref tx, blob b " |
| 256 | "WHERE (t.tagid=%d) AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) " |
| 257 | TAGVIEW_DEFAULT_FILTER |
| 258 | "ORDER BY tx.mtime DESC", |
| 259 | tagid); |
| 260 | char const * const colnames[] = { |
| 261 | "Tag Name", "Timestamp", "Version" |
| 262 | }; |
| @@ -269,11 +277,11 @@ | |
| 277 | @ <h2>Tag '%s(tagname)':</h2> |
| 278 | char * sql = mprintf( |
| 279 | "SELECT DISTINCT t.tagid, DATETIME(tx.mtime), b.uuid " |
| 280 | "FROM tag t, tagxref tx, blob b " |
| 281 | "WHERE (t.tagname='%q') AND (t.tagid=tx.tagid) AND (tx.srcid=b.rid) " |
| 282 | TAGVIEW_DEFAULT_FILTER |
| 283 | "ORDER BY tx.mtime DESC", |
| 284 | tagname); |
| 285 | char const * const colnames[] = { |
| 286 | "Tag ID", "Timestamp", "Version" |
| 287 | }; |
| @@ -289,11 +297,10 @@ | |
| 297 | |
| 298 | /* |
| 299 | ** WEBPAGE: /tagview |
| 300 | */ |
| 301 | void tagview_page(void){ |
| 302 | login_check_credentials(); |
| 303 | if( !g.okRdWiki ){ |
| 304 | login_needed(); |
| 305 | } |
| 306 | style_header("Tags"); |
| @@ -316,5 +323,7 @@ | |
| 323 | { |
| 324 | tagview_page_default(); |
| 325 | } |
| 326 | style_footer(); |
| 327 | } |
| 328 | |
| 329 | #undef TAGVIEW_DEFAULT_FILTER |
| 330 |