Fix memory leak in DbDelete()

This commit is contained in:
Jordan Bancino 2022-12-28 15:44:21 +00:00
parent 1a43ea6470
commit fbd7bf5944
3 changed files with 12 additions and 7 deletions

View file

@ -1,4 +1,4 @@
.Dd $Mdocdate: December 24 2022 $ .Dd $Mdocdate: December 28 2022 $
.Dt TELODENDRIA-CHANGELOG 7 .Dt TELODENDRIA-CHANGELOG 7
.Os Telodendria Project .Os Telodendria Project
.Sh NAME .Sh NAME
@ -101,6 +101,9 @@ safer ones.
.It .It
Fixed a memory leak that would occur when closing a Fixed a memory leak that would occur when closing a
database that contains cached objects. database that contains cached objects.
.It
Fixed a memory leak that would occur when deleting database
objects.
.El .El
.Pp .Pp
Misc: Misc:

View file

@ -47,7 +47,7 @@ typedef struct Job
} Job; } Job;
static Job * static Job *
JobCreate(long interval, JobFunc *func, void *args) JobCreate(long interval, JobFunc * func, void *args)
{ {
Job *job; Job *job;
@ -111,9 +111,9 @@ CronThread(void *args)
const unsigned long microTick = 100; const unsigned long microTick = 100;
unsigned long remainingTick = cron->tick - (te - ts); unsigned long remainingTick = cron->tick - (te - ts);
/* Only sleep for microTick ms at a time because if the /* Only sleep for microTick ms at a time because if the job
* job scheduler is supposed to stop before the tick is up, * scheduler is supposed to stop before the tick is up, we
* we don't want to be stuck in a long sleep */ * don't want to be stuck in a long sleep */
while (remainingTick >= microTick && !cron->stop) while (remainingTick >= microTick && !cron->stop)
{ {
UtilSleepMillis(microTick); UtilSleepMillis(microTick);
@ -156,7 +156,7 @@ CronCreate(unsigned long tick)
} }
void void
CronOnce(Cron * cron, JobFunc *func, void *args) CronOnce(Cron * cron, JobFunc * func, void *args)
{ {
Job *job; Job *job;
@ -177,7 +177,7 @@ void
} }
void void
CronEvery(Cron * cron, unsigned long interval, JobFunc *func, void *args) CronEvery(Cron * cron, unsigned long interval, JobFunc * func, void *args)
{ {
Job *job; Job *job;

View file

@ -662,6 +662,8 @@ DbDelete(Db * db, size_t nArgs,...)
pthread_mutex_unlock(&db->lock); pthread_mutex_unlock(&db->lock);
ArrayFree(args);
Free(file);
return ret; return ret;
} }