Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Retards

Name: Anonymous 2011-09-20 3:50

Error handling and comments make code unreadable.

My code:

    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    info_ptr = png_create_info_struct(png_ptr);


Retarded code by some n00b:

    /* Initialize the write struct. */
    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    if (png_ptr == NULL) {
        fclose(fp);
        return -1;
    }

    /* Initialize the info struct. */
    info_ptr = png_create_info_struct(png_ptr);
    if (info_ptr == NULL) {
        png_destroy_write_struct(&png_ptr, NULL);
        fclose(fp);
        return -1;
    }

    /* Set up error handling. */
    if (setjmp(png_jmpbuf(png_ptr))) {
        png_destroy_write_struct(&png_ptr, &info_ptr);
        fclose(fp);
        return -1;
    }

Name: Anonymous 2011-09-20 3:54

>>1
And this tard even calls `free` and checks for `malloc` for 0-return. BTW, OS frees memory for you, when program closes and with todays gigabytes of RAM program can leak memory for days! No need for `free` at all.

Name: Anonymous 2011-09-20 3:56

IHNBT

Name: Anonymous 2011-09-20 4:09

using libpng
arguing over unreadable code

IHBT

Name: Anonymous 2011-09-20 4:12

>>4
PNG is the only format GIMP can work with.

Name: Anonymous 2011-09-20 4:24

>>5
Who uses that furry piece of shit?

Name: Anonymous 2011-09-20 4:32

implying well defined code is unreadable

Name: Anonymous 2011-09-20 4:36

>>6
linux community

Name: Anonymous 2011-09-20 5:05

EXPERT PROGRAMMER'S ERROR HANDLING!!
    info_ptr = NULL;

    /* Initialize the write struct. */
    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    if (!png_ptr)
        goto error;

    /* Initialize the info struct. */
    info_ptr = png_create_info_struct(png_ptr);
    if (!info_ptr)
        goto error;
    if (setjmp(png_jmpbuf(png_ptr)))
        goto error;
   
    /* Insert normal exit here */

error:
    fclose(fp);
    if (png_ptr)
    {
        if (info_ptr)
            png_destroy_write_struct(&png_ptr, &info_ptr);
        else
            png_destroy_write_struct(&png_ptr, NULL);
    }
    return -1;

Name: Anonymous 2011-09-20 5:15

>>9
You forgot to strip comments. They're really redundant.

Name: Anonymous 2011-09-20 6:47

Nice. PNG cant store empty images. What a crappy format! Stinks like Linux.

libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data

Name: Anonymous 2011-09-20 6:47

>>10
you forgot to sage

Name: Anonymous 2011-09-20 8:46

>>9
HIBT?

Don't change these.
Name: Email:
Entire Thread Thread List