switch (c) {
case 'p':
- opts->pid = atoi(optarg);
+ {
+ struct pidlist *pid = alloc_pidlist();
+
+ if (pid == NULL) {
+ perror("malloc");
+ return;
+ }
+ pid->pid = atoi(optarg);
opts->parse_mask |= PARSE_PID;
+ list_add_tail(&pid->list, &opts->pidlist);
break;
+ }
case 'P':
opts->parse_mask |= PARSE_PROCESS_NAME;
opts->name = optarg;
"Results may be inaccurate\n");
}
- memset(&opts, 0, sizeof(opts));
+ init_parse_opts(&opts);
read_args(argc, argv, &opts);