1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-05 02:55:21 +02:00

eeshow/util.h (alloc_type_n): get rid of all these alloc_size(sizeof(foo), n)

This commit is contained in:
Werner Almesberger 2016-08-10 20:28:31 -03:00
parent 2ab72ab0e3
commit 8a0a79e461
5 changed files with 8 additions and 7 deletions

View File

@ -95,7 +95,7 @@ static void recurse(struct hist *h,
n_branches--;
memcpy(b, branches, sizeof(struct hist *) * n_branches);
h->older = alloc_size(sizeof(struct hist *) * n);
h->older = alloc_type_n(struct hist *, n);
h->n_older = n;
for (i = 0; i != n; i++) {

View File

@ -1009,7 +1009,7 @@ static const struct sheet *parse_files(struct gui_hist *hist,
goto fail;
if (hist->vcs_hist) {
hist->oids = alloc_size(sizeof(void *) * libs_open);
hist->oids = alloc_type_n(void *, libs_open);
for (i = 0; i != libs_open; i++)
hist->oids[i] = file_oid(lib_files + i);
if (prev && prev->vcs_hist) {

View File

@ -40,8 +40,8 @@ static bool parse_poly(struct lib_poly *poly, const char *line, int points)
int i, n;
poly->points = points;
poly->x = alloc_size(sizeof(int) * points);
poly->y = alloc_size(sizeof(int) * points);
poly->x = alloc_type_n(int, points);
poly->y = alloc_type_n(int, points);
for (i = 0; i != points; i++) {
if (sscanf(line, "%d %d %n",
poly->x + i, poly->y + i, &n) != 2)

View File

@ -174,7 +174,7 @@ int main(int argc, char **argv)
unsigned n = argc - optind;
char **args;
args = alloc_size(sizeof(char *) * n);
args = alloc_type_n(char *, n);
memcpy(args, argv + optind, sizeof(const char *) * n);
optind = 0; /* reset getopt */
@ -192,14 +192,14 @@ int main(int argc, char **argv)
if (dashdash == argc) {
gfx_argc = 1;
gfx_argv = alloc_size(sizeof(const char *) * 2);
gfx_argv = alloc_type_n(char *, 2);
gfx_argv[0] = (char *) (*ops)->name;
gfx_argv[1] = NULL;
} else {
gfx_argc = argc - dashdash - 1;
if (!gfx_argc)
usage(*argv);
gfx_argv = alloc_size(sizeof(const char *) * (gfx_argc + 1));
gfx_argv = alloc_type_n(char *, gfx_argc + 1);
memcpy(gfx_argv, argv + dashdash + 1,
sizeof(const char *) * (gfx_argc + 1));

View File

@ -28,6 +28,7 @@
alloc_size_tmp; })
#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
#define alloc_type_n(t, n) ((t *) alloc_size(sizeof(t) * (n)))
#define stralloc(s) \
({ char *stralloc_tmp = strdup(s); \