Rate My Shitty Code

github.com/fullnitrous/mandelbrot

Attached: 1.png (2000x2000, 589K)

Other urls found in this thread:

web.archive.org/web/20010121112800/http://user.cs.tu-berlin.de/~rms/AlmondBread/
web.archive.org/web/20080830072950/http://home.rochester.rr.com/jbxroads/interests/sci.fractals/source/edgetra.txt
twitter.com/SFWRedditGifs

It's shit.

>braces in the line after the function name
Stopped reading there.

This + no comments/shot explanation on what the code does and how + all code in one file = see me after class

>goto
Stop

aka the right way according to linux style guide
stop being butthurt snowflake

>goto/setjmp
>poorly spaced/paragraphed code and nasty ass code style
>dumb comments
>no assertations
>printf("gay")
>variables declared before they're used
>ghetto build scripts
I give you the D+, go read Clean Code and modern (MODERN, it's not 1999 anymore) C book and try again

You're leaking x & y in fractal, and you're not exiting if calloc fails. Fix that and it's fine. Code style sucks but that's personal preference.

They don't know i just copy pasted shit in one day (pepe smug)

possible memory leak on line 65, you should free png_byte at some point. also you don't need to use malloc at each iteration, since it's an image all rows are the same size, do it once outside the loop.

and holy shit write some comments you lazy bastard

>He doesn't use SIMD or multi-threading.
Fuck state of Jow Forums

why is it black and white, Mandelbrot should look all trippy like

not him, but isn't it freed on line 80? on line 67, row_pointers is made to point to row. i'm guessing png_free() frees memory or something?

>Doesn't even have infinite area
Yeah, it sucks OP

i'm as lazy as you are

mandelbrot is optimization masturbatory
this is the simplest slowest solution copy pasted from any explanation article ever

I dont know how to write build scripts so it's pretty cool for me.
Your mandelbrot render is stupid though, look up it's optimized implementation using gradients.

yeah well so, my friend made a mandelbrot thing in python and i just tried to translate it into c. How can it be optimized?

using goto is based, clean code virgins gtfo

based

>copy pasted shit in one day
>needing one day to copy and paste
see me after class

check bitqwit's Parallelism in C++ series and Boundary Tracing Algorithm
1) parallelism, either from threads or vector instructions
2) better algorithm than calculating every pixel, instead you are looking for boundaries and then fill the areas with color of neighbor boundary

web.archive.org/web/20010121112800/http://user.cs.tu-berlin.de/~rms/AlmondBread/
see web.archive.org/web/20080830072950/http://home.rochester.rr.com/jbxroads/interests/sci.fractals/source/edgetra.txt

sorry dady

it's also the only valid use of goto according to pretty much every coding style except too strict MISRA
goto error chains are sane pattern

thancccccc

What's wrong with all code in one file?

especially when it's under 200 lines

>he splits a small program into 10 separate files with comment blocks at the top that are larger than the code
This code doesn't need comments. The parts that aren't by-the-book library usage to write a png file or whatever are extremely obvious to anyone who knows how to compute the Mandelbrot set and do a linear transform.

yeah and that's at best 5% of the people who will ever read it. people in general don't know about math, if the code fails they'll say it's because you're doing arcane shit with magic numbers in it.

There is nothing wrong with using goto for error handling.

If you don't know math why are you reading a Mandelbrot program. If you want to learn about fractals, that's great, but read a book about that.

Similarly we don't require stickers on every part in a car describing its function in detail and how to repair or replace it.