-/* $OpenBSD: editor.c,v 1.283 2014/04/03 16:15:38 otto Exp $ */
+/* $OpenBSD: editor.c,v 1.284 2014/04/21 08:19:38 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
void set_duid(struct disklabel *);
struct diskchunk *free_chunks(struct disklabel *);
void mpcopy(char **, char **);
+void mpfree(char **);
int micmp(const void *, const void *);
int mpequal(char **, char **);
int get_bsize(struct disklabel *, int);
}
}
done:
- free(omountpoints);
- free(origmountpoints);
- free(tmpmountpoints);
+ mpfree(omountpoints);
+ mpfree(origmountpoints);
+ mpfree(tmpmountpoints);
if (disk_geop)
free(disk_geop);
return(error);
char *top;
for (i = 0; i < MAXPARTITIONS; i++) {
+ free(to[i]);
+ to[i] = NULL;
if (from[i] != NULL) {
- int len = strlen(from[i]) + 1;
-
- top = realloc(to[i], len);
- if (top == NULL)
+ to[i] = strdup(from[i]);
+ if (to[i] == NULL)
errx(4, "out of memory");
- to[i] = top;
- (void)strlcpy(to[i], from[i], len);
- } else if (to[i] != NULL) {
- free(to[i]);
- to[i] = NULL;
}
}
}
}
}
+void
+mpfree(char **mp)
+{
+ int part;
+
+ if (mp == NULL)
+ return;
+
+ for (part == 0; part < MAXPARTITIONS; part++)
+ free(mp[part]);
+
+ free(mp);
+}
+
int
get_offset(struct disklabel *lp, int partno)
{