Skip to content

Commit 86a9ce2

Browse files
committed
ch: Switch ch_monitor to use glib memory management
1 parent f105948 commit 86a9ce2

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/ch/ch_monitor.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ void virCHMonitorClose(virCHMonitorPtr mon)
12561256
VIR_WARN("Unable to remove CH socket file '%s'",
12571257
mon->socketpath);
12581258
}
1259-
VIR_FREE(mon->socketpath);
1259+
g_free(mon->socketpath);
12601260
}
12611261

12621262
if (mon->monitorpath) {
@@ -1449,7 +1449,7 @@ virCHMonitorPutNoContent(virCHMonitorPtr mon, const char *endpoint)
14491449
if (responseCode == 200 || responseCode == 204)
14501450
ret = 0;
14511451

1452-
VIR_FREE(url);
1452+
g_free(url);
14531453
curl_slist_free_all(headers);
14541454

14551455
return ret;
@@ -1549,7 +1549,7 @@ virCHMonitorGet(virCHMonitorPtr mon, const char *endpoint, virJSONValuePtr *resp
15491549
}
15501550
}
15511551

1552-
VIR_FREE(url);
1552+
g_free(url);
15531553
return ret;
15541554
}
15551555

@@ -1614,8 +1614,6 @@ virCHMonitorCreateVM(virCHMonitorPtr mon,
16141614
ret = 0;
16151615

16161616
curl_slist_free_all(headers);
1617-
VIR_FREE(url);
1618-
VIR_FREE(payload);
16191617
return ret;
16201618
}
16211619

@@ -1653,7 +1651,7 @@ static void
16531651
virCHMonitorThreadInfoFree(virCHMonitorPtr mon)
16541652
{
16551653
if (mon->threads)
1656-
VIR_FREE(mon->threads);
1654+
g_free(mon->threads);
16571655
mon->threads = NULL;
16581656
mon->nthreads = 0;
16591657
}
@@ -1704,8 +1702,7 @@ virCHMonitorRefreshThreadInfo(virCHMonitorPtr mon)
17041702

17051703
virCHMonitorThreadInfoFree(mon);
17061704

1707-
if (VIR_ALLOC_N(info, ntids) < 0)
1708-
return -1;
1705+
info = g_new(virCHMonitorThreadInfo, ntids);
17091706

17101707
for (i = 0; i < ntids; i++) {
17111708
g_autofree char *proc = NULL;
@@ -1809,14 +1806,12 @@ int virCHMonitorGetIOThreads(virCHMonitorPtr mon,
18091806
if (nthreads == 0)
18101807
return 0;
18111808

1812-
if (VIR_ALLOC_N(iothreadinfolist, nthreads) < 0)
1813-
goto cleanup;
1809+
iothreadinfolist = g_new(virDomainIOThreadInfoPtr, nthreads);
18141810

18151811
for (i = 0; i < nthreads; i++){
18161812
virBitmapPtr map = NULL;
18171813
if (mon->threads[i].type == virCHThreadTypeIO) {
1818-
if(VIR_ALLOC(iothreadinfo) < 0)
1819-
goto cleanup;
1814+
iothreadinfo = g_new(virDomainIOThreadInfo, 1);
18201815

18211816
iothreadinfo->iothread_id = mon->threads[i].tid;
18221817

@@ -1849,10 +1844,10 @@ int virCHMonitorGetIOThreads(virCHMonitorPtr mon,
18491844
cleanup:
18501845
if (iothreadinfolist) {
18511846
for (i = 0; i < niothreads; i++)
1852-
VIR_FREE(iothreadinfolist[i]);
1853-
VIR_FREE(iothreadinfolist);
1847+
g_free(iothreadinfolist[i]);
1848+
g_free(iothreadinfolist);
18541849
}
18551850
if (iothreadinfo)
1856-
VIR_FREE(iothreadinfo);
1851+
g_free(iothreadinfo);
18571852
return -1;
18581853
}

0 commit comments

Comments
 (0)