- him = malloc(sizeof (struct _mate));
- him->name = malloc(strlen(argv[i]) + 1);
- strcpy(him->name, argv[i]);
+ him = new(struct _mate, 1);
+ if (!him) {
+ ret = ENOMEM;
+ goto out;
+ }
+
+ him->name = strdup(argv[i]);
+ if (!him->name) {
+ free(him);
+ ret = ENOMEM;
+ goto out;
+ }
+