diff --git a/bin/rainbrot-gen b/bin/rainbrot-gen index ef9f4be..46dd23e 100755 Binary files a/bin/rainbrot-gen and b/bin/rainbrot-gen differ diff --git a/src/main.c b/src/main.c index a301f97..c2016b5 100644 --- a/src/main.c +++ b/src/main.c @@ -105,7 +105,12 @@ int main (int argc,char** argv) off_t fsize = (off_t)(sizeof(uint64_t))*args.re_size*args.im_size; int files[l]; uint64_t *maps[l]; - + uint64_t *zeros=calloc(args.re_size,sizeof(uint64_t)); /* String full of zeros, to write into new files in batches */ + if(!zeros) + { + fprintf(stderr,"Can't create a string full of zeros, quitting\n"); + return(1); + } for(int i=0; ire_size*sizeof(uint64_t*)); + if(!buff) + { + fprintf(stderr,"Can't allocate space for buffer array\n"); + exit(1); + } for(uint32_t x=0;xre_size;x++) { buff[x]=calloc(arg->im_size,sizeof(uint64_t)); @@ -29,6 +34,14 @@ void* worker(void *arg_v) exit(1); } } + + /* Keep track of which rows were written to */ + uint8_t *dirty_rows=calloc(arg->re_size,sizeof(uint8_t)); + if(!dirty_rows) + { + fprintf(stderr,"Can't allocate space for dirty rows marker, quitting\n"); + exit(1); + } /* Run until number of runs is reached */ while(1) @@ -90,8 +103,7 @@ void* worker(void *arg_v) while(inside==1); int64_t idx_x,idx_y; /* buff (2D array) coords */ - uint8_t dirty_rows[arg->re_size]; - for(uint32_t i=0;i< arg->re_size ;dirty_rows[i++]=0); /*zero dirty rows */ + /* Now we have a point which is outside, can iterate and draw */ Z=c; uint64_t i; @@ -132,10 +144,17 @@ void* worker(void *arg_v) } pthread_mutex_unlock(&arg->locks[k]); - for(uint32_t x=0;xre_size;x++)for(uint32_t y=0;yim_size;y++) - { - buff[x][y]=0; - } + for(uint32_t x=0;x< arg->re_size;x++) + { + if(dirty_rows[x]) + { + for(uint32_t y=0;y< arg->im_size;y++) + { + buff[x][y]=0; + } + dirty_rows[x]=0; + } + } } }