summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git-hist.c2
-rw-r--r--gui.c2
-rw-r--r--lib-parse.c4
-rw-r--r--main.c6
-rw-r--r--util.h1
5 files changed, 8 insertions, 7 deletions
diff --git a/git-hist.c b/git-hist.c
index 1b6d3e1..a016218 100644
--- a/git-hist.c
+++ b/git-hist.c
@@ -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++) {
diff --git a/gui.c b/gui.c
index 29c5722..9e867be 100644
--- a/gui.c
+++ b/gui.c
@@ -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) {
diff --git a/lib-parse.c b/lib-parse.c
index 9ea9679..0a19728 100644
--- a/lib-parse.c
+++ b/lib-parse.c
@@ -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)
diff --git a/main.c b/main.c
index 841cbf7..6583e3f 100644
--- a/main.c
+++ b/main.c
@@ -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));
diff --git a/util.h b/util.h
index ea40ce5..159e0df 100644
--- a/util.h
+++ b/util.h
@@ -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); \