Re: [PATCH 2/3] maintenance: use launchctl on macOS
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Nov 4, 2020, 14:17 UTC
- Message-ID
- <51d193c0-ef0c-aa5c-56c6-388499eaf2a7@gmail.com>
- In-Reply-To
- <e493b759-4565-e7d2-4a19-dee23c651119@gmail.com>
On 11/3/2020 4:21 PM, Derrick Stolee wrote:
Show 21 quoted lines
> On 11/3/2020 1:45 PM, Eric Sunshine wrote:
>> On Tue, Nov 3, 2020 at 9:05 AM Derrick Stolee via GitGitGadget
>>> +static int remove_plist(enum schedule_priority schedule)
>>> +{
>>> + const char *frequency = get_frequency(schedule);
>>> + char *name = get_service_name(frequency);
>>> + char *filename = get_service_filename(name);
>>> + int result = bootout(filename);
>>> + free(filename);
>>> + free(name);
>>> + return result;
>>> +}
>>
>> The result of get_service_name() is only ever passed to
>> get_service_filename(). If get_service_filename() made the call to
>> get_service_name() itself, it would free up callers from having to
>> remember to free(name), thus reducing the likelihood of a possible
>> leak.
>
> You're right. In an earlier version I thought I needed to add the
> name in the XML, but it turns out I did not.As I go through the effort to remove get_service_name() I find that actually the name is used in one place in the XML file:
+ "<key>Label</key><string>%s</string>\n"
This "Label" should match the filename, I believe. I can still be more careful about how often this name is actually required.
Thanks, -Stolee