aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-02-10 00:49:27 +0000
committerHarry Jeffery <harry@exec64.co.uk>2019-02-10 00:49:27 +0000
commit551464706c848526646a20b5b4172cda69f0e005 (patch)
tree44d39aead773aca821fcb51bd2ce18372ba99d10
parenta306cd551640286eb1ad189e87bf7815b5a94de8 (diff)
downloadimv-551464706c848526646a20b5b4172cda69f0e005.tar.gz
Tweak allocation sizeof operator usage
-rw-r--r--src/backend_freeimage.c10
-rw-r--r--src/backend_libjpeg.c6
-rw-r--r--src/backend_libpng.c6
-rw-r--r--src/backend_librsvg.c10
-rw-r--r--src/backend_libtiff.c8
-rw-r--r--src/binds.c4
-rw-r--r--src/bitmap.c2
-rw-r--r--src/commands.c6
-rw-r--r--src/image.c2
-rw-r--r--src/imv.c4
-rw-r--r--src/list.c2
-rw-r--r--src/navigator.c2
-rw-r--r--src/viewport.c2
13 files changed, 32 insertions, 32 deletions
diff --git a/src/backend_freeimage.c b/src/backend_freeimage.c
index c0fb655..bb3c089 100644
--- a/src/backend_freeimage.c
+++ b/src/backend_freeimage.c
@@ -50,7 +50,7 @@ static void source_free(struct imv_source *src)
static struct imv_bitmap *to_imv_bitmap(FIBITMAP *in_bmp)
{
- struct imv_bitmap *bmp = malloc(sizeof(struct imv_bitmap));
+ struct imv_bitmap *bmp = malloc(sizeof *bmp);
bmp->width = FreeImage_GetWidth(in_bmp);
bmp->height = FreeImage_GetHeight(in_bmp);
bmp->format = IMV_ARGB;
@@ -277,10 +277,10 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
return BACKEND_UNSUPPORTED;
}
- struct private *private = calloc(sizeof(struct private), 1);
+ struct private *private = calloc(1, sizeof(struct private));
private->format = fmt;
- struct imv_source *source = calloc(sizeof(struct imv_source), 1);
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup(path);
source->width = 0;
source->height = 0;
@@ -308,11 +308,11 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source
return BACKEND_UNSUPPORTED;
}
- struct private *private = calloc(sizeof(struct private), 1);
+ struct private *private = calloc(1, sizeof(struct private));
private->format = fmt;
private->memory = fmem;
- struct imv_source *source = calloc(sizeof(struct imv_source), 1);
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = NULL;
source->width = 0;
source->height = 0;
diff --git a/src/backend_libjpeg.c b/src/backend_libjpeg.c
index e83ddc3..ba3b1f9 100644
--- a/src/backend_libjpeg.c
+++ b/src/backend_libjpeg.c
@@ -45,7 +45,7 @@ static void source_free(struct imv_source *src)
static struct imv_bitmap *to_imv_bitmap(int width, int height, void *bitmap)
{
- struct imv_bitmap *bmp = malloc(sizeof(struct imv_bitmap));
+ struct imv_bitmap *bmp = malloc(sizeof *bmp);
bmp->width = width;
bmp->height = height;
bmp->format = IMV_ABGR;
@@ -153,7 +153,7 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
return BACKEND_UNSUPPORTED;
}
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup(path);
source->width = width;
source->height = height;
@@ -193,7 +193,7 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source
return BACKEND_UNSUPPORTED;
}
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup("-");
source->width = width;
source->height = height;
diff --git a/src/backend_libpng.c b/src/backend_libpng.c
index 3713ae8..2696007 100644
--- a/src/backend_libpng.c
+++ b/src/backend_libpng.c
@@ -38,7 +38,7 @@ static void source_free(struct imv_source *src)
static struct imv_bitmap *to_imv_bitmap(int width, int height, void *bitmap)
{
- struct imv_bitmap *bmp = malloc(sizeof(struct imv_bitmap));
+ struct imv_bitmap *bmp = malloc(sizeof *bmp);
bmp->width = width;
bmp->height = height;
bmp->format = IMV_ABGR;
@@ -132,7 +132,7 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
return BACKEND_UNSUPPORTED;
}
- struct private *private = malloc(sizeof(struct private));
+ struct private *private = malloc(sizeof *private);
private->file = f;
private->png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!private->png) {
@@ -165,7 +165,7 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
png_set_filler(private->png, 0xff, PNG_FILLER_AFTER);
png_read_update_info(private->png, private->info);
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup(path);
if (setjmp(png_jmpbuf(private->png))) {
free(source->name);
diff --git a/src/backend_librsvg.c b/src/backend_librsvg.c
index c9a91ff..86cbf00 100644
--- a/src/backend_librsvg.c
+++ b/src/backend_librsvg.c
@@ -36,7 +36,7 @@ static void source_free(struct imv_source *src)
static struct imv_bitmap *to_imv_bitmap(GdkPixbuf *bitmap)
{
- struct imv_bitmap *bmp = malloc(sizeof(struct imv_bitmap));
+ struct imv_bitmap *bmp = malloc(sizeof *bmp);
bmp->width = gdk_pixbuf_get_width(bitmap);
bmp->height = gdk_pixbuf_get_height(bitmap);
bmp->format = IMV_ARGB;
@@ -141,11 +141,11 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
return BACKEND_UNSUPPORTED;
}
- struct private *private = malloc(sizeof(struct private));
+ struct private *private = malloc(sizeof *private);
private->data = NULL;
private->len = 0;
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup(path);
source->width = 1024;
@@ -174,11 +174,11 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source
return BACKEND_UNSUPPORTED;
}
- struct private *private = malloc(sizeof(struct private));
+ struct private *private = malloc(sizeof *private);
private->data = data;
private->len = len;
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup("-");
source->width = 1024;
diff --git a/src/backend_libtiff.c b/src/backend_libtiff.c
index e837a46..a489cc1 100644
--- a/src/backend_libtiff.c
+++ b/src/backend_libtiff.c
@@ -81,7 +81,7 @@ static void source_free(struct imv_source *src)
static struct imv_bitmap *to_imv_bitmap(int width, int height, void *bitmap)
{
- struct imv_bitmap *bmp = malloc(sizeof(struct imv_bitmap));
+ struct imv_bitmap *bmp = malloc(sizeof *bmp);
bmp->width = width;
bmp->height = height;
bmp->format = IMV_ABGR;
@@ -169,7 +169,7 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
TIFFGetField(private.tiff, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(private.tiff, TIFFTAG_IMAGELENGTH, &height);
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup(path);
source->width = width;
source->height = height;
@@ -190,7 +190,7 @@ static enum backend_result open_path(const char *path, struct imv_source **src)
static enum backend_result open_memory(void *data, size_t len, struct imv_source **src)
{
- struct private *private = malloc(sizeof(struct private));
+ struct private *private = malloc(sizeof *private);
private->data = data;
private->len = len;
private->pos = 0;
@@ -207,7 +207,7 @@ static enum backend_result open_memory(void *data, size_t len, struct imv_source
TIFFGetField(private->tiff, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(private->tiff, TIFFTAG_IMAGELENGTH, &height);
- struct imv_source *source = calloc(1, sizeof(struct imv_source));
+ struct imv_source *source = calloc(1, sizeof *source);
source->name = strdup("-");
source->width = width;
source->height = height;
diff --git a/src/binds.c b/src/binds.c
index a38fe1a..0647d5a 100644
--- a/src/binds.c
+++ b/src/binds.c
@@ -42,7 +42,7 @@ static void destroy_bind_node(struct bind_node *bn)
struct imv_binds *imv_binds_create(void)
{
- struct imv_binds *binds = malloc(sizeof(struct imv_binds));
+ struct imv_binds *binds = malloc(sizeof *binds);
init_bind_node(&binds->bind_tree);
binds->keys = list_create();
return binds;
@@ -82,7 +82,7 @@ enum bind_result imv_binds_add(struct imv_binds *binds, const struct list *keys,
int child_index = list_find(node->suffixes, &compare_node_key, keys->items[i]);
if(child_index == -1) {
/* Create our new node */
- next_node = malloc(sizeof(struct bind_node));
+ next_node = malloc(sizeof *next_node);
init_bind_node(next_node);
next_node->key = keys->items[i];
list_append(node->suffixes, next_node);
diff --git a/src/bitmap.c b/src/bitmap.c
index ffae72c..38ca7a8 100644
--- a/src/bitmap.c
+++ b/src/bitmap.c
@@ -5,7 +5,7 @@
struct imv_bitmap *imv_bitmap_clone(struct imv_bitmap *bmp)
{
- struct imv_bitmap *copy = malloc(sizeof(struct imv_bitmap));
+ struct imv_bitmap *copy = malloc(sizeof *copy);
const size_t num_bytes = 4 * bmp->width * bmp->height;
copy->width = bmp->width;
copy->height = bmp->height;
diff --git a/src/commands.c b/src/commands.c
index 0fb8b46..ca40244 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -9,7 +9,7 @@ struct command {
struct imv_commands *imv_commands_create(void)
{
- struct imv_commands *cmds = malloc(sizeof(struct imv_commands));
+ struct imv_commands *cmds = malloc(sizeof *cmds);
cmds->command_list = list_create();
return cmds;
}
@@ -30,7 +30,7 @@ void imv_commands_free(struct imv_commands *cmds)
void imv_command_register(struct imv_commands *cmds, const char *command, void (*handler)(struct list*, const char*, void*))
{
- struct command *cmd = malloc(sizeof(struct command));
+ struct command *cmd = malloc(sizeof *cmd);
cmd->command = strdup(command);
cmd->handler = handler;
cmd->alias = NULL;
@@ -39,7 +39,7 @@ void imv_command_register(struct imv_commands *cmds, const char *command, void (
void imv_command_alias(struct imv_commands *cmds, const char *command, const char *alias)
{
- struct command *cmd = malloc(sizeof(struct command));
+ struct command *cmd = malloc(sizeof *cmd);
cmd->command = strdup(command);
cmd->handler = NULL;
cmd->alias = strdup(alias);
diff --git a/src/image.c b/src/image.c
index 3d28f06..5c1757e 100644
--- a/src/image.c
+++ b/src/image.c
@@ -18,7 +18,7 @@ struct imv_image {
struct imv_image *imv_image_create(SDL_Renderer *r)
{
- struct imv_image *image = malloc(sizeof(struct imv_image));
+ struct imv_image *image = malloc(sizeof *image);
memset(image, 0, sizeof(struct imv_image));
image->renderer = r;
diff --git a/src/imv.c b/src/imv.c
index 60954fe..34a4e9a 100644
--- a/src/imv.c
+++ b/src/imv.c
@@ -296,7 +296,7 @@ static void source_callback(struct imv_source_message *msg)
struct imv *imv_create(void)
{
- struct imv *imv = malloc(sizeof(struct imv));
+ struct imv *imv = malloc(sizeof *imv);
imv->quit = false;
imv->loading = false;
imv->fullscreen = false;
@@ -444,7 +444,7 @@ void imv_free(struct imv *imv)
void imv_install_backend(struct imv *imv, const struct imv_backend *backend)
{
- struct backend_chain *chain = malloc(sizeof(struct backend_chain));
+ struct backend_chain *chain = malloc(sizeof *chain);
chain->backend = backend;
chain->next = imv->backends;
imv->backends = chain;
diff --git a/src/list.c b/src/list.c
index 4cd7f24..a1261d0 100644
--- a/src/list.c
+++ b/src/list.c
@@ -2,7 +2,7 @@
struct list *list_create(void)
{
- struct list *list = malloc(sizeof(struct list));
+ struct list *list = malloc(sizeof *list);
list->len = 0;
list->cap = 64;
list->items = malloc(sizeof(void*) * list->cap);
diff --git a/src/navigator.c b/src/navigator.c
index e100224..4b996b2 100644
--- a/src/navigator.c
+++ b/src/navigator.c
@@ -27,7 +27,7 @@ struct imv_navigator {
struct imv_navigator *imv_navigator_create(void)
{
- struct imv_navigator *nav = malloc(sizeof(struct imv_navigator));
+ struct imv_navigator *nav = malloc(sizeof *nav);
memset(nav, 0, sizeof(struct imv_navigator));
nav->last_move_direction = 1;
return nav;
diff --git a/src/viewport.c b/src/viewport.c
index 65a269b..3d3251b 100644
--- a/src/viewport.c
+++ b/src/viewport.c
@@ -12,7 +12,7 @@ struct imv_viewport {
struct imv_viewport *imv_viewport_create(SDL_Window *window)
{
- struct imv_viewport *view = malloc(sizeof(struct imv_viewport));
+ struct imv_viewport *view = malloc(sizeof *view);
view->window = window;
view->scale = 1;
view->x = view->y = view->fullscreen = view->redraw = 0;