321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
*/
#define CGIDEBUG(X) if( g.fDebug ) cgi_debug X
#endif
Global g;
/*
** Infrastructure for fossil_atexit_free_this().
*/
static struct {
void* list[20]; /* Pointers to pass to fossil_free() during
** atexit(). */
int n; /* Number of items currently in this->list. */
} fossilFreeAtExit = { {0}, 0 };
/*
** If zMem is not NULL and there is space in fossil's atexit cleanup
** queue, zMem is added to that queue so that it will be passed to
** fossil_free() during the atexit() phase of app shutdown. If the
** queue is full or zMem is NULL, this function has no side effects.
**
** This is intended to be called by routines which allocate heap
** memory for static-scope values which otherwise won't be freed, and
** the static queue size is relatively small.
*/
void fossil_atexit_free_this(void * zMem){
if(zMem!=0
&& fossilFreeAtExit.n < (sizeof(fossilFreeAtExit.list)
/ sizeof(fossilFreeAtExit.list[0]))){
fossilFreeAtExit.list[fossilFreeAtExit.n++] = zMem;
}
}
/*
** atexit() handler which frees up "some" of the resources
** used by fossil.
*/
static void fossil_atexit(void) {
static int once = 0;
if( once++ ) return; /* Ensure that this routine only runs once */
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
*/
#define CGIDEBUG(X) if( g.fDebug ) cgi_debug X
#endif
Global g;
/*
** atexit() handler which frees up "some" of the resources
** used by fossil.
*/
static void fossil_atexit(void) {
static int once = 0;
if( once++ ) return; /* Ensure that this routine only runs once */
|
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
#endif
if(g.db){
db_close(0);
}
manifest_clear_cache();
content_clear_cache(1);
rebuild_clear_cache();
if(fossilFreeAtExit.n>0){
int i;
for(i = 0; i < fossilFreeAtExit.n; ++i){
fossil_free(fossilFreeAtExit.list[i]);
fossilFreeAtExit.list[i] = 0;
}
fossilFreeAtExit.n = 0;
}
/*
** FIXME: The next two lines cannot always be enabled; however, they
** are very useful for tracking down TH1 memory leaks.
*/
if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
if( g.interp ){
Th_DeleteInterp(g.interp); g.interp = 0;
|
<
<
<
<
<
<
<
<
|
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
#endif
if(g.db){
db_close(0);
}
manifest_clear_cache();
content_clear_cache(1);
rebuild_clear_cache();
/*
** FIXME: The next two lines cannot always be enabled; however, they
** are very useful for tracking down TH1 memory leaks.
*/
if( fossil_getenv("TH1_DELETE_INTERP")!=0 ){
if( g.interp ){
Th_DeleteInterp(g.interp); g.interp = 0;
|