
On Tue, 2016-04-05 at 17:26 +0200, Ján Tomko wrote:
+ * Since multiple cgroups can be part of the same line and some cgroup + * names can appear as part of other cgroup names (eg. 'cpu' is a + * prefix for both 'cpuacct' and 'cpuset'), it's not enough to simply + * check whether the cgroup name is present somewhere inside the file Also, they could be present in the path.
Right. I'll clarify that.
+ */ + + /* Look for the first colon. + * The part we're interested in starts right after it */ + if (!(start = strchr(line, ':'))) { + VIR_FREE(line); continue; This pattern keeps repeating. How about calling VIR_FREE the first thing in the loop and moving the getline call right after it?
Actually, after reading getline(3), I realized the leak was never there in the first place. The first time getline() is called, it is passed a NULL pointer for the buffer and 0 for the length, which instructs it to allocate an appropriately-sized buffer itself. Subsequent calls reuse the same buffer, growing it as needed. So we only really need a single VIR_FREE() call, right after the loop - exactly where it was before. Will post a respin shortly. Cheers. -- Andrea Bolognani Software Engineer - Virtualization Team