summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/pdfclean.c2
-rw-r--r--apps/pdfdraw.c4
-rw-r--r--apps/pdfextract.c2
-rw-r--r--apps/pdfinfo.c2
-rw-r--r--apps/win_main.c6
-rw-r--r--apps/x11_image.c2
-rw-r--r--apps/x11_main.c6
-rw-r--r--apps/xpsdraw.c4
-rw-r--r--draw/draw_affine.c2
-rw-r--r--draw/draw_device.c28
-rw-r--r--draw/draw_scale.c20
-rw-r--r--draw/draw_simple_scale.c20
-rw-r--r--fitz/base_context.c2
-rw-r--r--fitz/base_error.c6
-rw-r--r--fitz/base_getopt.c4
-rw-r--r--fitz/base_memory.c12
-rw-r--r--fitz/base_object.c6
-rw-r--r--fitz/base_string.c4
-rw-r--r--fitz/dev_list.c8
-rw-r--r--fitz/filt_basic.c8
-rw-r--r--fitz/filt_faxd.c2
-rw-r--r--fitz/filt_lzwd.c2
-rw-r--r--fitz/memento.c6
-rw-r--r--fitz/res_font.c10
-rw-r--r--fitz/res_halftone.c2
-rw-r--r--fitz/res_path.c2
-rw-r--r--fitz/stm_buffer.c2
-rw-r--r--fitz/stm_open.c2
-rw-r--r--pdf/pdf_annot.c4
-rw-r--r--pdf/pdf_crypt.c2
-rw-r--r--pdf/pdf_font.c2
-rw-r--r--pdf/pdf_interpret.c8
-rw-r--r--pdf/pdf_shade.c2
-rw-r--r--pdf/pdf_store.c2
-rw-r--r--pdf/pdf_xobject.c2
-rw-r--r--pdf/pdf_xref.c24
-rw-r--r--scripts/cmapdump.c4
37 files changed, 113 insertions, 113 deletions
diff --git a/apps/pdfclean.c b/apps/pdfclean.c
index 58453cfb..56d78082 100644
--- a/apps/pdfclean.c
+++ b/apps/pdfclean.c
@@ -785,7 +785,7 @@ int main(int argc, char **argv)
/* Do not renumber objects if encryption is in use, as the object
* numbers are baked into the streams/strings, and we can't currently
* cope with moving them. See bug 692627. */
- if (dogarbage >= 2 && xref->crypt == NULL)
+ if (dogarbage >= 2 && !xref->crypt)
renumberobjs();
writepdf();
diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c
index ff9f72a3..861d2b3f 100644
--- a/apps/pdfdraw.c
+++ b/apps/pdfdraw.c
@@ -363,9 +363,9 @@ int main(int argc, char **argv)
fz_accelerate();
ctx = fz_new_context(&fz_alloc_default);
- if (ctx == NULL)
+ if (!ctx)
{
- fprintf(stderr, "cannot init context\n");
+ fprintf(stderr, "cannot initialise context\n");
exit(1);
}
diff --git a/apps/pdfextract.c b/apps/pdfextract.c
index cb03d745..c32a25c5 100644
--- a/apps/pdfextract.c
+++ b/apps/pdfextract.c
@@ -127,7 +127,7 @@ static void savefont(fz_obj *dict, int num)
printf("extracting font %s\n", name);
f = fopen(name, "wb");
- if (f == NULL)
+ if (!f)
fz_throw(ctx, "Error creating font file");
n = fwrite(buf->data, 1, buf->len, f);
diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c
index 171317c9..bfa5f3b1 100644
--- a/apps/pdfinfo.c
+++ b/apps/pdfinfo.c
@@ -976,7 +976,7 @@ int main(int argc, char **argv)
ctx = fz_new_context(&fz_alloc_default);
if (!ctx)
{
- fprintf(stderr, "cannot initialise context");
+ fprintf(stderr, "cannot initialise context\n");
exit(1);
}
diff --git a/apps/win_main.c b/apps/win_main.c
index a64d1b08..99214904 100644
--- a/apps/win_main.c
+++ b/apps/win_main.c
@@ -340,7 +340,7 @@ void winopen()
/* Init DIB info for buffer */
dibinf = malloc(sizeof(BITMAPINFO) + 12);
- assert(dibinf != NULL);
+ assert(dibinf);
dibinf->bmiHeader.biSize = sizeof(dibinf->bmiHeader);
dibinf->bmiHeader.biPlanes = 1;
dibinf->bmiHeader.biBitCount = 32;
@@ -832,9 +832,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow
fz_accelerate();
ctx = fz_new_context(&fz_alloc_default);
- if (ctx == NULL)
+ if (!ctx)
{
- fprintf(stderr, "cannot init context");
+ fprintf(stderr, "cannot initialise context\n");
exit(1);
}
pdfapp_init(ctx, &gapp);
diff --git a/apps/x11_image.c b/apps/x11_image.c
index 9383c545..35b32c7e 100644
--- a/apps/x11_image.c
+++ b/apps/x11_image.c
@@ -285,7 +285,7 @@ create_pool(void)
info.pool[i] = createximage(info.display,
info.visual.visual, &info.shminfo[i], info.visual.depth,
WIDTH, HEIGHT);
- if (info.pool[i] == NULL) {
+ if (!info.pool[i]) {
return 0;
}
}
diff --git a/apps/x11_main.c b/apps/x11_main.c
index b875bc6a..23649a57 100644
--- a/apps/x11_main.c
+++ b/apps/x11_main.c
@@ -337,7 +337,7 @@ static void winblit(pdfapp_t *app)
{
int i = gapp.image->w*gapp.image->h;
unsigned char *color = malloc(i*4);
- if (color != NULL)
+ if (color)
{
unsigned char *s = gapp.image->samples;
unsigned char *d = color;
@@ -588,9 +588,9 @@ int main(int argc, char **argv)
struct timeval *timeout;
ctx = fz_new_context(&fz_alloc_default);
- if (ctx == NULL)
+ if (!ctx)
{
- fprintf(stderr, "failed to initialise context");
+ fprintf(stderr, "cannot initialise context\n");
exit(1);
}
diff --git a/apps/xpsdraw.c b/apps/xpsdraw.c
index 8b15ef3e..a7223574 100644
--- a/apps/xpsdraw.c
+++ b/apps/xpsdraw.c
@@ -315,9 +315,9 @@ int main(int argc, char **argv)
fz_accelerate();
ctx = fz_new_context(&fz_alloc_default);
- if (ctx == NULL)
+ if (!ctx)
{
- fprintf(stderr, "failed to initialise context");
+ fprintf(stderr, "cannot initialise context\n");
exit(1);
}
diff --git a/draw/draw_affine.c b/draw/draw_affine.c
index c1ee88f8..936f4a7f 100644
--- a/draw/draw_affine.c
+++ b/draw/draw_affine.c
@@ -679,7 +679,7 @@ fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *shape, fz_pixmap
if (dst->n == 4 && img->n == 2)
{
- assert(color == NULL);
+ assert(!color);
if (dolerp)
paintfn = fz_paint_affine_g2rgb_lerp;
else
diff --git a/draw/draw_device.c b/draw/draw_device.c
index cb6760ea..cc8f5474 100644
--- a/draw/draw_device.c
+++ b/draw/draw_device.c
@@ -74,7 +74,7 @@ static void fz_dump_blend(fz_pixmap *pix, const char *s)
{
char name[80];
- if (pix == NULL)
+ if (!pix)
return;
sprintf(name, "dump%02d.png", group_dump_count);
@@ -139,7 +139,7 @@ static void fz_knockout_begin(fz_draw_device *dev)
int i = dev->top;
do
prev = dev->stack[--i].dest;
- while (prev == NULL);
+ while (!prev);
fz_copy_pixmap_rect(dest, prev, bbox);
}
@@ -206,7 +206,7 @@ static void fz_knockout_end(fz_draw_device *dev)
printf(" (isolated)");
printf(" (knockout)");
#endif
- if ((blendmode == 0) && (shape == NULL))
+ if ((blendmode == 0) && (!shape))
fz_paint_pixmap(dev->dest, group, 255);
else
fz_blend_pixmap(dev->dest, group, 255, blendmode, isolated, shape);
@@ -871,7 +871,7 @@ fz_transform_pixmap(fz_context *ctx, fz_pixmap *image, fz_matrix *ctm, int x, in
if (gridfit)
fz_gridfit_matrix(&m);
scaled = fz_scale_pixmap(ctx, image, m.e, m.f, m.a, m.d);
- if (scaled == NULL)
+ if (!scaled)
return NULL;
ctm->a = scaled->w;
ctm->d = scaled->h;
@@ -887,7 +887,7 @@ fz_transform_pixmap(fz_context *ctx, fz_pixmap *image, fz_matrix *ctm, int x, in
if (gridfit)
fz_gridfit_matrix(&m);
scaled = fz_scale_pixmap(ctx, image, m.f, m.e, m.b, m.c);
- if (scaled == NULL)
+ if (!scaled)
return NULL;
ctm->b = scaled->w;
ctm->c = scaled->h;
@@ -949,7 +949,7 @@ fz_draw_fill_image(fz_device *devp, fz_pixmap *image, fz_matrix ctm, float alpha
{
int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
- if (scaled == NULL)
+ if (!scaled)
{
if (dx < 1)
dx = 1;
@@ -957,7 +957,7 @@ fz_draw_fill_image(fz_device *devp, fz_pixmap *image, fz_matrix ctm, float alpha
dy = 1;
scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy);
}
- if (scaled != NULL)
+ if (scaled)
image = scaled;
}
@@ -1011,7 +1011,7 @@ fz_draw_fill_image_mask(fz_device *devp, fz_pixmap *image, fz_matrix ctm,
{
int gridfit = alpha == 1.0f && !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
- if (scaled == NULL)
+ if (!scaled)
{
if (dx < 1)
dx = 1;
@@ -1019,7 +1019,7 @@ fz_draw_fill_image_mask(fz_device *devp, fz_pixmap *image, fz_matrix ctm,
dy = 1;
scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy);
}
- if (scaled != NULL)
+ if (scaled)
image = scaled;
}
@@ -1089,7 +1089,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_pixmap *image, fz_rect *rect, fz_mat
{
int gridfit = !(dev->flags & FZ_DRAWDEV_FLAGS_TYPE3);
scaled = fz_transform_pixmap(dev->ctx, image, &ctm, dev->dest->x, dev->dest->y, dx, dy, gridfit);
- if (scaled == NULL)
+ if (!scaled)
{
if (dx < 1)
dx = 1;
@@ -1097,7 +1097,7 @@ fz_draw_clip_image_mask(fz_device *devp, fz_pixmap *image, fz_rect *rect, fz_mat
dy = 1;
scaled = fz_scale_pixmap(dev->ctx, image, image->x, image->y, dx, dy);
}
- if (scaled != NULL)
+ if (scaled)
image = scaled;
}
@@ -1151,7 +1151,7 @@ fz_draw_pop_clip(fz_device *devp)
fz_dump_blend(mask, " with ");
#endif
fz_paint_pixmap_with_mask(dest, dev->dest, mask);
- if (shape != NULL)
+ if (shape)
{
assert(shape != dev->shape);
fz_paint_pixmap_with_mask(shape, dev->shape, mask);
@@ -1173,7 +1173,7 @@ fz_draw_pop_clip(fz_device *devp)
#ifdef DUMP_GROUP_BLENDS
dump_spaces(dev->top, "Clip End\n");
#endif
- assert(dest == NULL);
+ assert(!dest);
assert(shape == dev->shape);
}
}
@@ -1393,7 +1393,7 @@ fz_draw_end_group(fz_device *devp)
if (blendmode & FZ_BLEND_KNOCKOUT)
printf(" (knockout)");
#endif
- if ((blendmode == 0) && (shape == NULL))
+ if ((blendmode == 0) && (!shape))
fz_paint_pixmap(dev->dest, group, alpha * 255);
else
fz_blend_pixmap(dev->dest, group, alpha * 255, blendmode, isolated, shape);
diff --git a/draw/draw_scale.c b/draw/draw_scale.c
index fd3c3798..578a1d1e 100644
--- a/draw/draw_scale.c
+++ b/draw/draw_scale.c
@@ -298,7 +298,7 @@ new_weights(fz_context *ctx, fz_scale_filter *filter, int src_w, float dst_w, in
* plus room for an extra set of weights for reordering.
*/
weights = fz_malloc(ctx, sizeof(*weights)+(max_len+3)*(dst_w_i+1)*sizeof(int));
- if (weights == NULL)
+ if (!weights)
return NULL;
weights->count = -1;
weights->max_len = max_len;
@@ -527,7 +527,7 @@ make_weights(fz_context *ctx, int src_w, float x, float dst_w, fz_scale_filter *
window = filter->width / F;
DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window));
weights = new_weights(ctx, filter, src_w, dst_w, dst_w_int, n, flip);
- if (weights == NULL)
+ if (!weights)
return NULL;
for (j = 0; j < dst_w_int; j++)
{
@@ -1291,7 +1291,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
#endif /* SINGLE_PIXEL_SPECIALS */
{
contrib_cols = make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, src->n, flip_x);
- if (contrib_cols == NULL)
+ if (!contrib_cols)
goto cleanup;
}
#ifdef SINGLE_PIXEL_SPECIALS
@@ -1303,22 +1303,22 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
#endif /* SINGLE_PIXEL_SPECIALS */
{
contrib_rows = make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, src->n, flip_y);
- if (contrib_rows == NULL)
+ if (!contrib_rows)
goto cleanup;
}
- assert(contrib_cols == NULL || contrib_cols->count == dst_w_int);
- assert(contrib_rows == NULL || contrib_rows->count == dst_h_int);
+ assert(!contrib_cols || contrib_cols->count == dst_w_int);
+ assert(!contrib_rows || contrib_rows->count == dst_h_int);
output = fz_new_pixmap(ctx, src->colorspace, dst_w_int, dst_h_int);
output->x = dst_x_int;
output->y = dst_y_int;
/* Step 2: Apply the weights */
#ifdef SINGLE_PIXEL_SPECIALS
- if (contrib_rows == NULL)
+ if (!contrib_rows)
{
/* Only 1 source pixel high. */
- if (contrib_cols == NULL)
+ if (!contrib_cols)
{
/* Only 1 pixel in the entire image! */
duplicate_single_pixel(output->samples, src->samples, src->n, dst_w_int, dst_h_int);
@@ -1329,7 +1329,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
scale_single_row(output->samples, src->samples, contrib_cols, src->w, dst_h_int);
}
}
- else if (contrib_cols == NULL)
+ else if (!contrib_cols)
{
/* Only 1 source pixel wide. Scale the col and duplicate. */
scale_single_col(output->samples, src->samples, contrib_rows, src->h, src->n, dst_w_int, flip_y);
@@ -1344,7 +1344,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
if (temp_span <= 0 || temp_rows > INT_MAX / temp_span)
goto cleanup;
temp = fz_malloc_array(ctx, temp_span*temp_rows, sizeof(int));
- if (temp == NULL)
+ if (!temp)
goto cleanup;
switch (src->n)
{
diff --git a/draw/draw_simple_scale.c b/draw/draw_simple_scale.c
index dcd5cd68..cd8ac2b9 100644
--- a/draw/draw_simple_scale.c
+++ b/draw/draw_simple_scale.c
@@ -254,7 +254,7 @@ new_weights(fz_context *ctx, fz_scale_filter *filter, int src_w, float dst_w, in
* plus room for an extra set of weights for reordering.
*/
weights = fz_malloc(ctx, sizeof(*weights)+(max_len+3)*(dst_w_i+1)*sizeof(int));
- if (weights == NULL)
+ if (!weights)
return NULL;
weights->count = -1;
weights->max_len = max_len;
@@ -465,7 +465,7 @@ make_weights(fz_context *ctx, int src_w, float x, float dst_w, fz_scale_filter *
window = filter->width / F;
DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window));
weights = new_weights(ctx, filter, src_w, dst_w, dst_w_int, n, flip);
- if (weights == NULL)
+ if (!weights)
return NULL;
for (j = 0; j < dst_w_int; j++)
{
@@ -1250,7 +1250,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
#endif /* SINGLE_PIXEL_SPECIALS */
{
contrib_cols = make_weights(ctx, src->w, x, w, filter, 0, dst_w_int, src->n, flip_x);
- if (contrib_cols == NULL)
+ if (!contrib_cols)
goto cleanup;
}
#ifdef SINGLE_PIXEL_SPECIALS
@@ -1262,22 +1262,22 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
#endif /* SINGLE_PIXEL_SPECIALS */
{
contrib_rows = make_weights(ctx, src->h, y, h, filter, 1, dst_h_int, src->n, flip_y);
- if (contrib_rows == NULL)
+ if (!contrib_rows)
goto cleanup;
}
- assert(contrib_cols == NULL || contrib_cols->count == dst_w_int);
- assert(contrib_rows == NULL || contrib_rows->count == dst_h_int);
+ assert(!contrib_cols || contrib_cols->count == dst_w_int);
+ assert(!contrib_rows || contrib_rows->count == dst_h_int);
output = fz_new_pixmap(ctx, src->colorspace, dst_w_int, dst_h_int);
output->x = dst_x_int;
output->y = dst_y_int;
/* Step 2: Apply the weights */
#ifdef SINGLE_PIXEL_SPECIALS
- if (contrib_rows == NULL)
+ if (!contrib_rows)
{
/* Only 1 source pixel high. */
- if (contrib_cols == NULL)
+ if (!contrib_cols)
{
/* Only 1 pixel in the entire image! */
duplicate_single_pixel(output->samples, src->samples, src->n, dst_w_int, dst_h_int);
@@ -1288,7 +1288,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
scale_single_row(output->samples, src->samples, contrib_cols, src->w, dst_h_int);
}
}
- else if (contrib_cols == NULL)
+ else if (!contrib_cols)
{
/* Only 1 source pixel wide. Scale the col and duplicate. */
scale_single_col(output->samples, src->samples, contrib_rows, src->h, src->n, dst_w_int, flip_y);
@@ -1303,7 +1303,7 @@ fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, floa
if (temp_span <= 0 || temp_rows > INT_MAX / temp_span)
goto cleanup;
temp = fz_calloc(ctx, temp_span*temp_rows, sizeof(unsigned char));
- if (temp == NULL)
+ if (!temp)
goto cleanup;
switch (src->n)
{
diff --git a/fitz/base_context.c b/fitz/base_context.c
index 0eacd6eb..3d9df6aa 100644
--- a/fitz/base_context.c
+++ b/fitz/base_context.c
@@ -11,7 +11,7 @@ fz_obj *(*fz_resolve_indirect)(fz_obj*) = fz_resolve_indirect_null;
void
fz_free_context(fz_context *ctx)
{
- if (ctx == NULL)
+ if (!ctx)
return;
/* Other finalisation calls go here (in reverse order) */
diff --git a/fitz/base_error.c b/fitz/base_error.c
index 3373016f..1184981c 100644
--- a/fitz/base_error.c
+++ b/fitz/base_error.c
@@ -51,7 +51,7 @@ static void throw(fz_error_context *ex)
void fz_push_try(fz_error_context *ex)
{
- assert(ex != NULL);
+ assert(ex);
if (ex->top + 1 >= nelem(ex->stack))
{
fprintf(stderr, "exception stack overflow!\n");
@@ -62,8 +62,8 @@ void fz_push_try(fz_error_context *ex)
char *fz_caught(fz_context *ctx)
{
- assert(ctx != NULL);
- assert(ctx->error != NULL);
+ assert(ctx);
+ assert(ctx->error);
return ctx->error->message;
}
diff --git a/fitz/base_getopt.c b/fitz/base_getopt.c
index 2c198ba1..2a6e5ac4 100644
--- a/fitz/base_getopt.c
+++ b/fitz/base_getopt.c
@@ -25,7 +25,7 @@ getopt(int argc, char *argv[], char *optstring)
optarg = NULL;
- if (scan == NULL || *scan == '\0') {
+ if (!scan || *scan == '\0') {
if (optind == 0)
optind++;
@@ -43,7 +43,7 @@ getopt(int argc, char *argv[], char *optstring)
c = *scan++;
place = strchr(optstring, c);
- if (place == NULL || c == ':') {
+ if (!place || c == ':') {
fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
return '?';
}
diff --git a/fitz/base_memory.c b/fitz/base_memory.c
index 43ec0dd9..79ae38b0 100644
--- a/fitz/base_memory.c
+++ b/fitz/base_memory.c
@@ -4,7 +4,7 @@ void *
fz_malloc(fz_context *ctx, unsigned int size)
{
void *p = ctx->alloc->malloc(ctx->alloc->user, size);
- if (p == NULL)
+ if (!p)
fz_throw(ctx, "malloc of %d bytes failed", size);
return p;
}
@@ -27,7 +27,7 @@ fz_malloc_array(fz_context *ctx, unsigned int count, unsigned int size)
fz_throw(ctx, "malloc of array (%d x %d bytes) failed (integer overflow)", count, size);
p = ctx->alloc->malloc(ctx->alloc->user, count * size);
- if (p == NULL)
+ if (!p)
fz_throw(ctx, "malloc of array (%d x %d bytes) failed", count, size);
return p;
}
@@ -61,7 +61,7 @@ fz_calloc(fz_context *ctx, unsigned int count, unsigned int size)
}
p = ctx->alloc->malloc(ctx->alloc->user, count * size);
- if (p == NULL)
+ if (!p)
{
fz_throw(ctx, "calloc (%d x %d bytes) failed", count, size);
}
@@ -84,7 +84,7 @@ fz_calloc_no_throw(fz_context *ctx, unsigned int count, unsigned int size)
}
p = ctx->alloc->malloc(ctx->alloc->user, count * size);
- if (p != NULL)
+ if (p)
{
memset(p, 0, count*size);
}
@@ -106,7 +106,7 @@ fz_resize_array(fz_context *ctx, void *p, unsigned int count, unsigned int size)
fz_throw(ctx, "resize array (%d x %d bytes) failed (integer overflow)", count, size);
np = ctx->alloc->realloc(ctx->alloc->user, p, count * size);
- if (np == NULL)
+ if (!np)
fz_throw(ctx, "resize array (%d x %d bytes) failed", count, size);
return np;
}
@@ -149,7 +149,7 @@ fz_strdup_no_throw(fz_context *ctx, char *s)
{
int len = strlen(s) + 1;
char *ns = fz_malloc_no_throw(ctx, len);
- if (ns != NULL)
+ if (ns)
memcpy(ns, s, len);
return ns;
}
diff --git a/fitz/base_object.c b/fitz/base_object.c
index 8c79e4c6..957396ea 100644
--- a/fitz/base_object.c
+++ b/fitz/base_object.c
@@ -136,7 +136,7 @@ fz_new_indirect(fz_context *ctx, int num, int gen, void *xref)
fz_obj *
fz_keep_obj(fz_obj *obj)
{
- assert(obj != NULL);
+ assert(obj);
obj->refs ++;
return obj;
}
@@ -358,7 +358,7 @@ fz_objcmp(fz_obj *a, fz_obj *b)
static char *
fz_objkindstr(fz_obj *obj)
{
- if (obj == NULL)
+ if (!obj)
return "<NULL>";
switch (obj->kind)
{
@@ -834,7 +834,7 @@ fz_free_dict(fz_obj *obj)
void
fz_drop_obj(fz_obj *obj)
{
- if (obj == NULL)
+ if (!obj)
return;
if (--obj->refs)
return;
diff --git a/fitz/base_string.c b/fitz/base_string.c
index 76748e20..dd9f8ea2 100644
--- a/fitz/base_string.c
+++ b/fitz/base_string.c
@@ -11,8 +11,8 @@ char *
fz_strsep(char **stringp, const char *delim)
{
char *ret = *stringp;
- if (ret == NULL) return NULL;
- if ((*stringp = strpbrk(*stringp, delim)) != NULL)
+ if (!ret) return NULL;
+ if ((*stringp = strpbrk(*stringp, delim)))
*((*stringp)++) = '\0';
return ret;
}
diff --git a/fitz/dev_list.c b/fitz/dev_list.c
index 63e9eee0..cbb988df 100644
--- a/fitz/dev_list.c
+++ b/fitz/dev_list.c
@@ -154,7 +154,7 @@ fz_append_display_node(fz_display_list *list, fz_display_node *node)
update = list->stack[list->top].update;
if (list->tiled == 0)
{
- if (update != NULL)
+ if (update)
{
*update = fz_intersect_rect(*update, list->stack[list->top].rect);
node->rect = *update;
@@ -255,7 +255,7 @@ fz_list_clip_path(fz_device *dev, fz_path *path, fz_rect *rect, int even_odd, fz
fz_display_node *node;
node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_PATH, ctm, NULL, NULL, 0);
node->rect = fz_bound_path(path, NULL, ctm);
- if (rect != NULL)
+ if (rect)
node->rect = fz_intersect_rect(node->rect, *rect);
node->item.path = fz_clone_path(dev->ctx, path);
node->flag = even_odd;
@@ -268,7 +268,7 @@ fz_list_clip_stroke_path(fz_device *dev, fz_path *path, fz_rect *rect, fz_stroke
fz_display_node *node;
node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_STROKE_PATH, ctm, NULL, NULL, 0);
node->rect = fz_bound_path(path, stroke, ctm);
- if (rect != NULL)
+ if (rect)
node->rect = fz_intersect_rect(node->rect, *rect);
node->item.path = fz_clone_path(dev->ctx, path);
node->stroke = fz_clone_stroke_state(dev->ctx, stroke);
@@ -378,7 +378,7 @@ fz_list_clip_image_mask(fz_device *dev, fz_pixmap *image, fz_rect *rect, fz_matr
fz_display_node *node;
node = fz_new_display_node(dev->ctx, FZ_CMD_CLIP_IMAGE_MASK, ctm, NULL, NULL, 0);
node->rect = fz_transform_rect(ctm, fz_unit_rect);
- if (rect != NULL)
+ if (rect)
node->rect = fz_intersect_rect(node->rect, *rect);
node->item.image = fz_keep_pixmap(image);
fz_append_display_node(dev->user, node);
diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c
index 1ab70f7f..3d211645 100644
--- a/fitz/filt_basic.c
+++ b/fitz/filt_basic.c
@@ -40,7 +40,7 @@ fz_open_null(fz_stream *chain, int len)
{
struct null_filter *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(struct null_filter));
state->chain = chain;
state->remain = len;
@@ -282,7 +282,7 @@ fz_open_a85d(fz_stream *chain)
{
fz_a85d *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(fz_a85d));
state->chain = chain;
state->rp = state->bp;
@@ -370,7 +370,7 @@ fz_open_rld(fz_stream *chain)
{
fz_rld *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(fz_rld));
state->chain = chain;
state->run = 0;
@@ -496,7 +496,7 @@ fz_open_aesd(fz_stream *chain, unsigned char *key, unsigned keylen)
{
fz_aesd *state;
- assert(chain != NULL);
+ assert(chain);
state = fz_malloc(chain->ctx, sizeof(fz_aesd));
state->chain = chain;
aes_setkey_dec(&state->aes, key, keylen * 8);
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c
index f94a2cd6..98430e0d 100644
--- a/fitz/filt_faxd.c
+++ b/fitz/filt_faxd.c
@@ -666,7 +666,7 @@ fz_open_faxd(fz_stream *chain, fz_obj *params)
fz_obj *obj;
fz_context *ctx;
- assert(chain != NULL);
+ assert(chain);
ctx = chain->ctx;
fax = fz_malloc(ctx, sizeof(fz_faxd));
fax->chain = chain;
diff --git a/fitz/filt_lzwd.c b/fitz/filt_lzwd.c
index 76cad305..7ca78fc3 100644
--- a/fitz/filt_lzwd.c
+++ b/fitz/filt_lzwd.c
@@ -170,7 +170,7 @@ fz_open_lzwd(fz_stream *chain, fz_obj *params)
fz_obj *obj;
int i;
- assert(chain != NULL);
+ assert(chain);
lzw = fz_malloc(chain->ctx, sizeof(fz_lzwd));
lzw->chain = chain;
lzw->eod = 0;
diff --git a/fitz/memento.c b/fitz/memento.c
index 24e19e3a..c6677a0f 100644
--- a/fitz/memento.c
+++ b/fitz/memento.c
@@ -423,7 +423,7 @@ static void Memento_fin(void)
globals.numFrees, globals.numReallocs);
fprintf(stderr, "Average allocation size %d bytes\n",
globals.totalAlloc/globals.numMallocs);
- if (globals.used.head != NULL) {
+ if (globals.used.head) {
Memento_listBlocks();
Memento_breakpoint();
}
@@ -937,7 +937,7 @@ int Memento_find(void *a)
data.blk = NULL;
data.flags = 0;
Memento_appBlocks(&globals.used, Memento_containsAddr, &data);
- if (data.blk != NULL) {
+ if (data.blk) {
fprintf(stderr, "Address 0x%p is in %sallocated block 0x%p(size=%d,num=%d)\n",
data.addr,
(data.flags == 1 ? "" : (data.flags == 2 ?
@@ -948,7 +948,7 @@ int Memento_find(void *a)
data.blk = NULL;
data.flags = 0;
Memento_appBlocks(&globals.free, Memento_containsAddr, &data);
- if (data.blk != NULL) {
+ if (data.blk) {
fprintf(stderr, "Address 0x%p is in %sfreed block 0x%p(size=%d,num=%d)\n",
data.addr,
(data.flags == 1 ? "" : (data.flags == 2 ?
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 3fea732a..60374746 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -131,9 +131,9 @@ void fz_new_font_context(fz_context *ctx)
void fz_free_font_context(fz_context *ctx)
{
- if (ctx->font == NULL)
+ if (!ctx->font)
return;
- /* assert(ctx->ftlib == NULL); */
+ /* assert(!ctx->ftlib); */
/* assert(ctx->ftlib_refs == 0); */
fz_free(ctx, ctx->font);
}
@@ -147,7 +147,7 @@ char *ft_error_string(int err)
{
const struct ft_error *e;
- for (e = ft_errors; e->str != NULL; e++)
+ for (e = ft_errors; e->str; e++)
if (e->err == err)
return e->str;
@@ -553,7 +553,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co
}
else if (dev->flags & FZ_CHARPROC_COLOR)
{
- if (model == NULL)
+ if (!model)
fz_warn(ctx, "colored type3 glyph wanted in masked context");
}
else
@@ -579,7 +579,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co
fz_free_device(dev);
fz_free_glyph_cache(ctx, cache);
- if (model == NULL)
+ if (!model)
{
result = fz_alpha_from_gray(ctx, glyph, 0);
fz_drop_pixmap(ctx, glyph);
diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c
index ad2ab694..b1b8d7b4 100644
--- a/fitz/res_halftone.c
+++ b/fitz/res_halftone.c
@@ -162,7 +162,7 @@ fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht)
unsigned char *ht_line, *o, *p;
int w, h, x, y, n, pstride, ostride;
- if (pix == NULL || ht == NULL)
+ if (!pix || !ht)
return NULL;
assert(pix->n == 2); /* Mono + Alpha */
diff --git a/fitz/res_path.c b/fitz/res_path.c
index cea720e9..894e25a8 100644
--- a/fitz/res_path.c
+++ b/fitz/res_path.c
@@ -19,7 +19,7 @@ fz_clone_path(fz_context *ctx, fz_path *old)
{
fz_path *path;
- assert(old != NULL);
+ assert(old);
path = fz_malloc(ctx, sizeof(fz_path));
path->len = old->len;
path->cap = old->len;
diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c
index 8eb2bedf..2722be1a 100644
--- a/fitz/stm_buffer.c
+++ b/fitz/stm_buffer.c
@@ -26,7 +26,7 @@ fz_keep_buffer(fz_buffer *buf)
void
fz_drop_buffer(fz_context *ctx, fz_buffer *buf)
{
- if (buf == NULL)
+ if (!buf)
return;
if (--buf->refs == 0)
{
diff --git a/fitz/stm_open.c b/fitz/stm_open.c
index 9f657f27..eade9788 100644
--- a/fitz/stm_open.c
+++ b/fitz/stm_open.c
@@ -41,7 +41,7 @@ fz_keep_stream(fz_stream *stm)
void
fz_close(fz_stream *stm)
{
- if (stm == NULL)
+ if (!stm)
return;
stm->refs --;
if (stm->refs == 0)
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
index 2a569e5c..9cfb8f93 100644
--- a/pdf/pdf_annot.c
+++ b/pdf/pdf_annot.c
@@ -14,7 +14,7 @@ pdf_free_link(fz_context *ctx, pdf_link *link)
fz_free(ctx, link);
link = next;
}
- while(link != NULL);
+ while(link);
}
static fz_obj *
@@ -166,7 +166,7 @@ pdf_free_annot(fz_context *ctx, pdf_annot *annot)
fz_free(ctx, annot);
annot = next;
}
- while (annot != NULL);
+ while (annot);
}
static void
diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c
index 692ed09e..940d966a 100644
--- a/pdf/pdf_crypt.c
+++ b/pdf/pdf_crypt.c
@@ -266,7 +266,7 @@ pdf_parse_crypt_filter(fz_context *ctx, pdf_crypt_filter *cf, fz_obj *cf_obj, ch
cf->method = PDF_CRYPT_NONE;
cf->length = defaultlength;
- if (cf_obj == NULL)
+ if (!cf_obj)
{
cf->method = (is_identity ? PDF_CRYPT_NONE : PDF_CRYPT_RC4);
return;
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index d4d26f79..dfd4782c 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -745,7 +745,7 @@ load_cid_font(pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode
fontdesc = pdf_new_font_desc(ctx);
descriptor = fz_dict_gets(dict, "FontDescriptor");
- if (descriptor == NULL)
+ if (!descriptor)
fz_throw(ctx, "syntaxerror: missing font descriptor");
pdf_load_font_descriptor(fontdesc, xref, descriptor, collection, basefont);
diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c
index b82b4297..b6089ca0 100644
--- a/pdf/pdf_interpret.c
+++ b/pdf/pdf_interpret.c
@@ -112,7 +112,7 @@ ocg_intents_include(pdf_ocg_descriptor *desc, char *name)
return 1;
/* In the absence of a specified intent, it's 'View' */
- if (desc->intent == NULL)
+ if (!desc->intent)
return (strcmp(name, "View") == 0);
if (fz_is_name(desc->intent))
@@ -146,7 +146,7 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
pdf_ocg_descriptor *desc = csi->xref->ocg;
/* If no ocg descriptor, everything is visible */
- if (desc == NULL)
+ if (!desc)
return 0;
/* If we've been handed a name, look it up in the properties. */
@@ -155,7 +155,7 @@ pdf_is_hidden_ocg(fz_obj *ocg, pdf_csi *csi, fz_obj *rdb)
ocg = fz_dict_gets(fz_dict_gets(rdb, "Properties"), fz_to_name(ocg));
}
/* If we haven't been given an ocg at all, then we're visible */
- if (ocg == NULL)
+ if (!ocg)
return 0;
fz_strlcpy(event_state, csi->event, sizeof event_state);
@@ -1469,7 +1469,7 @@ static void pdf_run_BDC(pdf_csi *csi, fz_obj *rdb)
}
ocg = fz_dict_gets(fz_dict_gets(rdb, "Properties"), csi->name);
- if (ocg == NULL)
+ if (!ocg)
{
/* No Properties array, or name not found in the properties
* means visible. */
diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c
index 3803f77e..e0a2804b 100644
--- a/pdf/pdf_shade.c
+++ b/pdf/pdf_shade.c
@@ -1033,7 +1033,7 @@ pdf_load_shading_dict(pdf_xref *xref, fz_obj *dict, fz_matrix transform)
for (i = 0; i < funcs; i++)
{
func[i] = pdf_load_function(xref, fz_array_get(obj, i));
- if (func[i] == NULL)
+ if (!func[i])
fz_throw(ctx, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj));
}
}
diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c
index 4d20e859..26a2ad9b 100644
--- a/pdf/pdf_store.c
+++ b/pdf/pdf_store.c
@@ -74,7 +74,7 @@ pdf_find_item(fz_context *ctx, pdf_store *store, pdf_store_drop_fn *drop_func, f
if (!store)
return NULL;
- if (key == NULL)
+ if (!key)
return NULL;
if (fz_is_indirect(key))
diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c
index 81ef52fa..b4c03b8b 100644
--- a/pdf/pdf_xobject.c
+++ b/pdf/pdf_xobject.c
@@ -51,7 +51,7 @@ pdf_load_xobject(pdf_xref *xref, fz_obj *dict)
if (obj)
{
form->colorspace = pdf_load_colorspace(xref, obj);
- if (form->colorspace == NULL)
+ if (!form->colorspace)
fz_throw(ctx, "cannot load xobject colorspace");
}
}
diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c
index 65c695f6..c27e9d75 100644
--- a/pdf/pdf_xref.c
+++ b/pdf/pdf_xref.c
@@ -480,7 +480,7 @@ pdf_ocg_set_config(pdf_xref *xref, int config)
char *name;
obj = fz_dict_gets(fz_dict_gets(xref->trailer, "Root"), "OCProperties");
- if (obj == NULL)
+ if (!obj)
{
if (config == 0)
return;
@@ -490,20 +490,20 @@ pdf_ocg_set_config(pdf_xref *xref, int config)
if (config == 0)
{
cobj = fz_dict_gets(obj, "D");
- if (cobj == NULL)
+ if (!cobj)
fz_throw(xref->ctx, "No default OCG config");
}
else
{
cobj = fz_array_get(fz_dict_gets(obj, "Configs"), config);
- if (cobj == NULL)
+ if (!cobj)
fz_throw(xref->ctx, "Illegal OCG config");
}
- if (desc->intent != NULL)
+ if (desc->intent)
fz_drop_obj(desc->intent);
desc->intent = fz_dict_gets(cobj, "Intent");
- if (desc->intent != NULL)
+ if (desc->intent)
fz_keep_obj(desc->intent);
len = desc->len;
@@ -587,10 +587,10 @@ pdf_read_ocg(pdf_xref *xref)
fz_var(desc);
obj = fz_dict_gets(fz_dict_gets(xref->trailer, "Root"), "OCProperties");
- if (obj == NULL)
+ if (!obj)
return;
ocg = fz_dict_gets(obj, "OCGs");
- if (ocg == NULL || !fz_is_array(ocg))
+ if (!ocg || !fz_is_array(ocg))
/* Not ever supposed to happen, but live with it. */
return;
len = fz_array_len(ocg);
@@ -611,7 +611,7 @@ pdf_read_ocg(pdf_xref *xref)
}
fz_catch(ctx)
{
- if (desc != NULL)
+ if (desc)
fz_free(ctx, desc->ocgs);
fz_free(ctx, desc);
fz_rethrow(ctx);
@@ -623,7 +623,7 @@ pdf_read_ocg(pdf_xref *xref)
static void
pdf_free_ocg(fz_context *ctx, pdf_ocg_descriptor *desc)
{
- if (desc == NULL)
+ if (!desc)
return;
if (desc->intent)
@@ -707,8 +707,8 @@ pdf_open_xref_with_stream(fz_stream *file, char *password)
pdf_repair_obj_stms(xref);
}
- hasroot = fz_dict_gets(xref->trailer, "Root") != NULL;
- hasinfo = fz_dict_gets(xref->trailer, "Info") != NULL;
+ hasroot = fz_dict_gets(xref->trailer, "Root");
+ hasinfo = fz_dict_gets(xref->trailer, "Info");
for (i = 1; i < xref->len; i++)
{
@@ -779,7 +779,7 @@ pdf_free_xref(pdf_xref *xref)
int i;
fz_context *ctx;
- if (xref == NULL)
+ if (!xref)
return;
ctx = xref->ctx;
diff --git a/scripts/cmapdump.c b/scripts/cmapdump.c
index f2d70631..286f2abe 100644
--- a/scripts/cmapdump.c
+++ b/scripts/cmapdump.c
@@ -50,9 +50,9 @@ main(int argc, char **argv)
}
ctx = fz_new_context(&fz_alloc_default);
- if (ctx == NULL)
+ if (!ctx)
{
- fprintf(stderr, "failed to initialise!\n");
+ fprintf(stderr, "cannot initialise context\n");
return 1;
}