mirror of
https://github.com/emersion/kanshi
synced 2024-09-19 18:35:44 +02:00
Don't strdup command line arguments.
They live forever, so there's no need to manage them with dynamic memory.
This commit is contained in:
parent
2c66d57ed0
commit
b6613c2eac
7
main.c
7
main.c
@ -488,14 +488,13 @@ static const struct option long_options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char *config_arg = NULL;
|
const char *config_arg = NULL;
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt_long(argc, argv, "hc:", long_options, NULL)) != -1) {
|
while ((opt = getopt_long(argc, argv, "hc:", long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'c':
|
case 'c':
|
||||||
free(config_arg);
|
config_arg = optarg;
|
||||||
config_arg = strdup(optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
fprintf(stderr, usage, argv[0]);
|
fprintf(stderr, usage, argv[0]);
|
||||||
@ -511,8 +510,6 @@ int main(int argc, char *argv[]) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(config_arg);
|
|
||||||
|
|
||||||
struct wl_display *display = wl_display_connect(NULL);
|
struct wl_display *display = wl_display_connect(NULL);
|
||||||
if (display == NULL) {
|
if (display == NULL) {
|
||||||
fprintf(stderr, "failed to connect to display\n");
|
fprintf(stderr, "failed to connect to display\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user