Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/stbi remove malloc casts.



details:   https://anonhg.NetBSD.org/src/rev/44533c2db366
branches:  trunk
changeset: 343064:44533c2db366
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 21 17:16:48 2016 +0000

description:
remove malloc casts.

diffstat:

 sys/dev/stbi/stb_image.c |  46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diffs (209 lines):

diff -r b040cce3f303 -r 44533c2db366 sys/dev/stbi/stb_image.c
--- a/sys/dev/stbi/stb_image.c  Thu Jan 21 17:14:05 2016 +0000
+++ b/sys/dev/stbi/stb_image.c  Thu Jan 21 17:16:48 2016 +0000
@@ -430,7 +430,7 @@
 #endif
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.6 2013/09/15 14:06:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.7 2016/01/21 17:16:48 christos Exp $");
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
@@ -985,7 +985,7 @@
    if (req_comp == img_n) return data;
    assert(req_comp >= 1 && req_comp <= 4);
 
-   good = (unsigned char *) MALLOC(req_comp * x * y);
+   good = MALLOC(req_comp * x * y);
    if (good == NULL) {
       FREE(data);
       return epuc("outofmem", "Out of memory");
@@ -1025,7 +1025,7 @@
 static float   *ldr_to_hdr(stbi_uc *data, int x, int y, int comp)
 {
    int i,k,n;
-   float *output = (float *) MALLOC(x * y * comp * sizeof(float));
+   float *output = MALLOC(x * y * comp * sizeof(float));
    if (output == NULL) { FREE(data); return epf("outofmem", "Out of memory"); }
    // compute number of non-alpha components
    if (comp & 1) n = comp; else n = comp-1;
@@ -1043,7 +1043,7 @@
 static stbi_uc *hdr_to_ldr(float   *data, int x, int y, int comp)
 {
    int i,k,n;
-   stbi_uc *output = (stbi_uc *) MALLOC(x * y * comp);
+   stbi_uc *output = MALLOC(x * y * comp);
    if (output == NULL) { FREE(data); return epuc("outofmem", "Out of memory"); }
    // compute number of non-alpha components
    if (comp & 1) n = comp; else n = comp-1;
@@ -1983,7 +1983,7 @@
 
          // allocate line buffer big enough for upsampling off the edges
          // with upsample factor of 4
-         z->img_comp[k].linebuf = (uint8 *) MALLOC(z->s.img_x + 3);
+         z->img_comp[k].linebuf = MALLOC(z->s.img_x + 3);
          if (!z->img_comp[k].linebuf) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); }
 
          r->hs      = z->img_h_max / z->img_comp[k].h;
@@ -2001,7 +2001,7 @@
       }
 
       // can't error after this so, this is safe
-      output = (uint8 *) MALLOC(n * z->s.img_x * z->s.img_y + 1);
+      output = MALLOC(n * z->s.img_x * z->s.img_y + 1);
       if (!output) { cleanup_jpeg(z); return epuc("outofmem", "Out of memory"); }
 
       // now go ahead and resample
@@ -2074,7 +2074,7 @@
 {
    #ifdef STBI_SMALL_STACK
    unsigned char *result;
-   jpeg *j = (jpeg *) MALLOC(sizeof(*j));
+   jpeg *j = MALLOC(sizeof(*j));
    start_mem(&j->s, buffer, len);
    result = load_jpeg_image(j,x,y,comp,req_comp);
    FREE(j);
@@ -2512,7 +2512,7 @@
 char *stbi_zlib_decode_malloc_guesssize(const char * buffer, int len, int initial_size, int *outlen)
 {
    zbuf a;
-   char *p = (char *) MALLOC(initial_size);
+   char *p = MALLOC(initial_size);
    if (p == NULL) return NULL;
    a.zbuffer = (uint8 const *) buffer;
    a.zbuffer_end = (uint8 const *) buffer + len;
@@ -2533,7 +2533,7 @@
 char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)
 {
    zbuf a;
-   char *p = (char *) MALLOC(initial_size);
+   char *p = MALLOC(initial_size);
    if (p == NULL) return NULL;
    a.zbuffer = (uint8 const *) buffer;
    a.zbuffer_end = (uint8 const *) buffer + len;
@@ -2560,7 +2560,7 @@
 char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)
 {
    zbuf a;
-   char *p = (char *) MALLOC(16384);
+   char *p = MALLOC(16384);
    if (p == NULL) return NULL;
    a.zbuffer = (uint8 const *) buffer;
    a.zbuffer_end = (uint8 const *) buffer+len;
@@ -2657,7 +2657,7 @@
    int img_n = s->img_n; // copy it into a local for later
    assert(out_n == s->img_n || out_n == s->img_n+1);
    if (stbi_png_partial) y = 1;
-   a->out = (uint8 *) MALLOC(x * y * out_n);
+   a->out = MALLOC(x * y * out_n);
    if (!a->out) return e("outofmem", "Out of memory");
    if (!stbi_png_partial) {
       if (s->img_x == x && s->img_y == y) {
@@ -2737,7 +2737,7 @@
    stbi_png_partial = 0;
 
    // de-interlacing
-   final = (uint8 *) MALLOC(a->s.img_x * a->s.img_y * out_n);
+   final = MALLOC(a->s.img_x * a->s.img_y * out_n);
    for (p=0; p < 7; ++p) {
       int xorig[] = { 0,4,0,2,0,1,0 };
       int yorig[] = { 0,0,4,0,2,0,1 };
@@ -2797,7 +2797,7 @@
    uint32 i, pixel_count = a->s.img_x * a->s.img_y;
    uint8 *p, *temp_out, *orig = a->out;
 
-   p = (uint8 *) MALLOC(pixel_count * pal_img_n);
+   p = MALLOC(pixel_count * pal_img_n);
    if (p == NULL) return e("outofmem", "Out of memory");
 
    // between here and FREE(out) below, exiting would leak
@@ -3305,7 +3305,7 @@
       target = req_comp;
    else
       target = s->img_n; // if they want monochrome, we'll post-convert
-   out = (stbi_uc *) MALLOC(target * s->img_x * s->img_y);
+   out = MALLOC(target * s->img_x * s->img_y);
    if (!out) return epuc("outofmem", "Out of memory");
    if (bpp < 16) {
       int z=0;
@@ -3594,7 +3594,7 @@
       //   force a new number of components
       *comp = tga_bits_per_pixel/8;
    }
-   tga_data = (unsigned char*)MALLOC( tga_width * tga_height * req_comp );
+   tga_data = MALLOC( tga_width * tga_height * req_comp );
 
    //   skip to the data's starting position (offset usually = 0)
    skip(s, tga_offset );
@@ -3604,7 +3604,7 @@
       //   any data to skip? (offset usually = 0)
       skip(s, tga_palette_start );
       //   load the palette
-      tga_palette = (unsigned char*)MALLOC( tga_palette_len * tga_palette_bits / 8 );
+      tga_palette = MALLOC( tga_palette_len * tga_palette_bits / 8 );
       if (!getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 ))
          return NULL;
    }
@@ -3868,7 +3868,7 @@
       return epuc("bad compression", "PSD has an unknown compression format");
 
    // Create the destination image.
-   out = (stbi_uc *) MALLOC(4 * w*h);
+   out = MALLOC(4 * w*h);
    if (!out) return epuc("outofmem", "Out of memory");
    pixelCount = w*h;
 
@@ -4178,7 +4178,7 @@
    get16(s); //skip `pad'
 
    // intermediate buffer is RGBA
-   result = (stbi_uc *) MALLOC(x*y*4);
+   result = MALLOC(x*y*4);
    memset(result, 0xff, x*y*4);
 
    if (!pic_load2(s,x,y,comp, result)) {
@@ -4474,14 +4474,14 @@
 
    if (g->out == 0) {
       if (!stbi_gif_header(s, g, comp,0))     return 0; // failure_reason set by stbi_gif_header
-      g->out = (uint8 *) MALLOC(4 * g->w * g->h);
+      g->out = MALLOC(4 * g->w * g->h);
       if (g->out == 0)                      return epuc("outofmem", "Out of memory");
       stbi_fill_gif_background(g);
    } else {
       // animated-gif-only path
       if (((g->eflags & 0x1C) >> 2) == 3) {
          old_out = g->out;
-         g->out = (uint8 *) MALLOC(4 * g->w * g->h);
+         g->out = MALLOC(4 * g->w * g->h);
          if (g->out == 0)                   return epuc("outofmem", "Out of memory");
          memcpy(g->out, old_out, g->w*g->h*4);
       }
@@ -4603,7 +4603,7 @@
    stbi_gif *pg;
 
    #ifdef STBI_SMALL_STACK
-   pg = (stbi_gif *) MALLOC(sizeof(*pg));
+   pg = MALLOC(sizeof(*pg));
    if (pg == NULL)
       return NULL;
    #else
@@ -4788,7 +4788,7 @@
    if (req_comp == 0) req_comp = 3;
 
    // Read data
-   hdr_data = (float *) MALLOC(height * width * req_comp * sizeof(float));
+   hdr_data = MALLOC(height * width * req_comp * sizeof(float));
 
    // Load image data
    // image data is stored as some number of sca
@@ -4827,7 +4827,7 @@
          len <<= 8;
          len |= get8(s);
          if (len != width) { FREE(hdr_data); FREE(scanline); return epf("invalid decoded scanline length", "corrupt HDR"); }
-         if (scanline == NULL) scanline = (stbi_uc *) MALLOC(width * 4);
+         if (scanline == NULL) scanline = MALLOC(width * 4);
             
          for (k = 0; k < 4; ++k) {
             i = 0;



Home | Main Index | Thread Index | Old Index