mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 20:14:04 +02:00
eeshow/util.h (alloc_type_n): get rid of all these alloc_size(sizeof(foo), n)
This commit is contained in:
parent
2ab72ab0e3
commit
8a0a79e461
@ -95,7 +95,7 @@ static void recurse(struct hist *h,
|
|||||||
n_branches--;
|
n_branches--;
|
||||||
memcpy(b, branches, sizeof(struct hist *) * 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;
|
h->n_older = n;
|
||||||
|
|
||||||
for (i = 0; i != n; i++) {
|
for (i = 0; i != n; i++) {
|
||||||
|
@ -1009,7 +1009,7 @@ static const struct sheet *parse_files(struct gui_hist *hist,
|
|||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (hist->vcs_hist) {
|
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++)
|
for (i = 0; i != libs_open; i++)
|
||||||
hist->oids[i] = file_oid(lib_files + i);
|
hist->oids[i] = file_oid(lib_files + i);
|
||||||
if (prev && prev->vcs_hist) {
|
if (prev && prev->vcs_hist) {
|
||||||
|
@ -40,8 +40,8 @@ static bool parse_poly(struct lib_poly *poly, const char *line, int points)
|
|||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
poly->points = points;
|
poly->points = points;
|
||||||
poly->x = alloc_size(sizeof(int) * points);
|
poly->x = alloc_type_n(int, points);
|
||||||
poly->y = alloc_size(sizeof(int) * points);
|
poly->y = alloc_type_n(int, points);
|
||||||
for (i = 0; i != points; i++) {
|
for (i = 0; i != points; i++) {
|
||||||
if (sscanf(line, "%d %d %n",
|
if (sscanf(line, "%d %d %n",
|
||||||
poly->x + i, poly->y + i, &n) != 2)
|
poly->x + i, poly->y + i, &n) != 2)
|
||||||
|
@ -174,7 +174,7 @@ int main(int argc, char **argv)
|
|||||||
unsigned n = argc - optind;
|
unsigned n = argc - optind;
|
||||||
char **args;
|
char **args;
|
||||||
|
|
||||||
args = alloc_size(sizeof(char *) * n);
|
args = alloc_type_n(char *, n);
|
||||||
memcpy(args, argv + optind, sizeof(const char *) * n);
|
memcpy(args, argv + optind, sizeof(const char *) * n);
|
||||||
|
|
||||||
optind = 0; /* reset getopt */
|
optind = 0; /* reset getopt */
|
||||||
@ -192,14 +192,14 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (dashdash == argc) {
|
if (dashdash == argc) {
|
||||||
gfx_argc = 1;
|
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[0] = (char *) (*ops)->name;
|
||||||
gfx_argv[1] = NULL;
|
gfx_argv[1] = NULL;
|
||||||
} else {
|
} else {
|
||||||
gfx_argc = argc - dashdash - 1;
|
gfx_argc = argc - dashdash - 1;
|
||||||
if (!gfx_argc)
|
if (!gfx_argc)
|
||||||
usage(*argv);
|
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,
|
memcpy(gfx_argv, argv + dashdash + 1,
|
||||||
sizeof(const char *) * (gfx_argc + 1));
|
sizeof(const char *) * (gfx_argc + 1));
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
alloc_size_tmp; })
|
alloc_size_tmp; })
|
||||||
|
|
||||||
#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
|
#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
|
||||||
|
#define alloc_type_n(t, n) ((t *) alloc_size(sizeof(t) * (n)))
|
||||||
|
|
||||||
#define stralloc(s) \
|
#define stralloc(s) \
|
||||||
({ char *stralloc_tmp = strdup(s); \
|
({ char *stralloc_tmp = strdup(s); \
|
||||||
|
Loading…
Reference in New Issue
Block a user