Fossil SCM

Removed fossil_atexit_free_this() because it effectively costs more static memory than it cleans up in dynamic memory.

stephan 2019-12-21 03:45 memleak-fixes
Commit 99cb2ccd94b45dde65a91c1338296a98c9a6bd29ebb507ad32577b0646bb3af7
-1
--- src/db.c
+++ src/db.c
@@ -1632,11 +1632,10 @@
16321632
if( zRepo && !file_is_absolute_path(zRepo) ){
16331633
char * zFree = zRepo;
16341634
zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
16351635
fossil_free(zFree);
16361636
}
1637
- fossil_atexit_free_this(zRepo);
16381637
}
16391638
return zRepo;
16401639
}
16411640
16421641
/*
16431642
--- src/db.c
+++ src/db.c
@@ -1632,11 +1632,10 @@
1632 if( zRepo && !file_is_absolute_path(zRepo) ){
1633 char * zFree = zRepo;
1634 zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
1635 fossil_free(zFree);
1636 }
1637 fossil_atexit_free_this(zRepo);
1638 }
1639 return zRepo;
1640 }
1641
1642 /*
1643
--- src/db.c
+++ src/db.c
@@ -1632,11 +1632,10 @@
1632 if( zRepo && !file_is_absolute_path(zRepo) ){
1633 char * zFree = zRepo;
1634 zRepo = mprintf("%s%s", g.zLocalRoot, zRepo);
1635 fossil_free(zFree);
1636 }
 
1637 }
1638 return zRepo;
1639 }
1640
1641 /*
1642
-35
--- src/main.c
+++ src/main.c
@@ -323,37 +323,10 @@
323323
324324
#endif
325325
326326
Global g;
327327
328
-/*
329
-** Infrastructure for fossil_atexit_free_this().
330
-*/
331
-static struct {
332
- void* list[20]; /* Pointers to pass to fossil_free() during
333
- ** atexit(). */
334
- int n; /* Number of items currently in this->list. */
335
-} fossilFreeAtExit = { {0}, 0 };
336
-
337
-/*
338
-** If zMem is not NULL and there is space in fossil's atexit cleanup
339
-** queue, zMem is added to that queue so that it will be passed to
340
-** fossil_free() during the atexit() phase of app shutdown. If the
341
-** queue is full or zMem is NULL, this function has no side effects.
342
-**
343
-** This is intended to be called by routines which allocate heap
344
-** memory for static-scope values which otherwise won't be freed, and
345
-** the static queue size is relatively small.
346
-*/
347
-void fossil_atexit_free_this(void * zMem){
348
- if(zMem!=0
349
- && fossilFreeAtExit.n < (sizeof(fossilFreeAtExit.list)
350
- / sizeof(fossilFreeAtExit.list[0]))){
351
- fossilFreeAtExit.list[fossilFreeAtExit.n++] = zMem;
352
- }
353
-}
354
-
355328
/*
356329
** atexit() handler which frees up "some" of the resources
357330
** used by fossil.
358331
*/
359332
static void fossil_atexit(void) {
@@ -393,18 +366,10 @@
393366
db_close(0);
394367
}
395368
manifest_clear_cache();
396369
content_clear_cache(1);
397370
rebuild_clear_cache();
398
- if(fossilFreeAtExit.n>0){
399
- int i;
400
- for(i = 0; i < fossilFreeAtExit.n; ++i){
401
- fossil_free(fossilFreeAtExit.list[i]);
402
- fossilFreeAtExit.list[i] = 0;
403
- }
404
- fossilFreeAtExit.n = 0;
405
- }
406371
/*
407372
** FIXME: The next two lines cannot always be enabled; however, they
408373
** are very useful for tracking down TH1 memory leaks.
409374
*/
410375
if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
411376
--- src/main.c
+++ src/main.c
@@ -323,37 +323,10 @@
323
324 #endif
325
326 Global g;
327
328 /*
329 ** Infrastructure for fossil_atexit_free_this().
330 */
331 static struct {
332 void* list[20]; /* Pointers to pass to fossil_free() during
333 ** atexit(). */
334 int n; /* Number of items currently in this->list. */
335 } fossilFreeAtExit = { {0}, 0 };
336
337 /*
338 ** If zMem is not NULL and there is space in fossil's atexit cleanup
339 ** queue, zMem is added to that queue so that it will be passed to
340 ** fossil_free() during the atexit() phase of app shutdown. If the
341 ** queue is full or zMem is NULL, this function has no side effects.
342 **
343 ** This is intended to be called by routines which allocate heap
344 ** memory for static-scope values which otherwise won't be freed, and
345 ** the static queue size is relatively small.
346 */
347 void fossil_atexit_free_this(void * zMem){
348 if(zMem!=0
349 && fossilFreeAtExit.n < (sizeof(fossilFreeAtExit.list)
350 / sizeof(fossilFreeAtExit.list[0]))){
351 fossilFreeAtExit.list[fossilFreeAtExit.n++] = zMem;
352 }
353 }
354
355 /*
356 ** atexit() handler which frees up "some" of the resources
357 ** used by fossil.
358 */
359 static void fossil_atexit(void) {
@@ -393,18 +366,10 @@
393 db_close(0);
394 }
395 manifest_clear_cache();
396 content_clear_cache(1);
397 rebuild_clear_cache();
398 if(fossilFreeAtExit.n>0){
399 int i;
400 for(i = 0; i < fossilFreeAtExit.n; ++i){
401 fossil_free(fossilFreeAtExit.list[i]);
402 fossilFreeAtExit.list[i] = 0;
403 }
404 fossilFreeAtExit.n = 0;
405 }
406 /*
407 ** FIXME: The next two lines cannot always be enabled; however, they
408 ** are very useful for tracking down TH1 memory leaks.
409 */
410 if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
411
--- src/main.c
+++ src/main.c
@@ -323,37 +323,10 @@
323
324 #endif
325
326 Global g;
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328 /*
329 ** atexit() handler which frees up "some" of the resources
330 ** used by fossil.
331 */
332 static void fossil_atexit(void) {
@@ -393,18 +366,10 @@
366 db_close(0);
367 }
368 manifest_clear_cache();
369 content_clear_cache(1);
370 rebuild_clear_cache();
 
 
 
 
 
 
 
 
371 /*
372 ** FIXME: The next two lines cannot always be enabled; however, they
373 ** are very useful for tracking down TH1 memory leaks.
374 */
375 if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
376
--- src/manifest.c
+++ src/manifest.c
@@ -1950,12 +1950,10 @@
19501950
blob_zero(&brief);
19511951
if( once ){
19521952
once = 0;
19531953
zTitleExpr = db_get("ticket-title-expr", "title");
19541954
zStatusColumn = db_get("ticket-status-column", "status");
1955
- fossil_atexit_free_this(zTitleExpr);
1956
- fossil_atexit_free_this(zStatusColumn);
19571955
}
19581956
zTitle = db_text("unknown",
19591957
"SELECT \"%w\" FROM ticket WHERE tkt_uuid=%Q",
19601958
zTitleExpr, pManifest->zTicketUuid
19611959
);
19621960
--- src/manifest.c
+++ src/manifest.c
@@ -1950,12 +1950,10 @@
1950 blob_zero(&brief);
1951 if( once ){
1952 once = 0;
1953 zTitleExpr = db_get("ticket-title-expr", "title");
1954 zStatusColumn = db_get("ticket-status-column", "status");
1955 fossil_atexit_free_this(zTitleExpr);
1956 fossil_atexit_free_this(zStatusColumn);
1957 }
1958 zTitle = db_text("unknown",
1959 "SELECT \"%w\" FROM ticket WHERE tkt_uuid=%Q",
1960 zTitleExpr, pManifest->zTicketUuid
1961 );
1962
--- src/manifest.c
+++ src/manifest.c
@@ -1950,12 +1950,10 @@
1950 blob_zero(&brief);
1951 if( once ){
1952 once = 0;
1953 zTitleExpr = db_get("ticket-title-expr", "title");
1954 zStatusColumn = db_get("ticket-status-column", "status");
 
 
1955 }
1956 zTitle = db_text("unknown",
1957 "SELECT \"%w\" FROM ticket WHERE tkt_uuid=%Q",
1958 zTitleExpr, pManifest->zTicketUuid
1959 );
1960

Keyboard Shortcuts

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