diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-10-02 03:42:10 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-10-02 03:42:10 +0000 |
commit | 0bf54ddfa2a0efcf6142ad1292abbfa26fe0bee3 (patch) | |
tree | 5e1255181517b72c3c5670da6be95e5ba8624614 /lib | |
parent | 9184208ec40610f6856907fa00d814ae093d3e3b (diff) | |
download | netpbm-mirror-0bf54ddfa2a0efcf6142ad1292abbfa26fe0bee3.tar.gz netpbm-mirror-0bf54ddfa2a0efcf6142ad1292abbfa26fe0bee3.tar.xz netpbm-mirror-0bf54ddfa2a0efcf6142ad1292abbfa26fe0bee3.zip |
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@82 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libpm.c | 14 | ||||
-rw-r--r-- | lib/libppmfloyd.c | 41 | ||||
-rw-r--r-- | lib/pm.h | 3 | ||||
-rw-r--r-- | lib/ppmfloyd.h | 18 |
4 files changed, 47 insertions, 29 deletions
diff --git a/lib/libpm.c b/lib/libpm.c index df59e6c4..f36b7a50 100644 --- a/lib/libpm.c +++ b/lib/libpm.c @@ -35,7 +35,9 @@ #define _LARGE_FILE_API /* This makes the the x64() functions available on AIX */ +#include <unistd.h> #include <stdio.h> +#include <fcntl.h> #include <stdarg.h> #include <string.h> #include <errno.h> @@ -43,6 +45,7 @@ #ifdef __DJGPP__ #include <io.h> #endif +#include <time.h> #include "pm_c_util.h" #include "version.h" @@ -782,6 +785,15 @@ pm_arg0toprogname(const char arg0[]) { +unsigned int +pm_randseed(void) { + + return time(NULL) ^ getpid(); + +} + + + /* File open/close that handles "-" as stdin/stdout and checks errors. */ FILE* @@ -986,7 +998,7 @@ pm_make_tmpfile(FILE ** const filePP, const char * dirseparator; const char * error; - fnamelen = strlen (pm_progname) + 10; /* "/" + "_XXXXXX\0" */ + fnamelen = strlen(pm_progname) + 10; /* "/" + "_XXXXXX\0" */ tmpdir = tmpDir(); diff --git a/lib/libppmfloyd.c b/lib/libppmfloyd.c index 071c3c36..ec6256ff 100644 --- a/lib/libppmfloyd.c +++ b/lib/libppmfloyd.c @@ -85,35 +85,36 @@ allocateFi(int const cols) { ppm_fs_info * -ppm_fs_init(int cols, pixval maxval, int flags) { +ppm_fs_init(unsigned int const cols, + pixval const maxval, + unsigned int const flags) { - ppm_fs_info *fi; + ppm_fs_info * fiP; - fi = allocateFi(cols); + fiP = allocateFi(cols); - fi->lefttoright = 1; - fi->cols = cols; - fi->maxval = maxval; - fi->flags = flags; - - if( flags & FS_RANDOMINIT ) { + fiP->lefttoright = 1; + fiP->cols = cols; + fiP->maxval = maxval; + fiP->flags = flags; + + if (flags & FS_RANDOMINIT) { unsigned int i; - srand((int)(time(0) ^ getpid())); - for( i = 0; i < cols +2; i++ ) { + srand(pm_randseed()); + for (i = 0; i < cols +2; ++i) { /* random errors in [-1..+1] */ - fi->thisrederr[i] = rand() % 32 - 16; - fi->thisgreenerr[i] = rand() % 32 - 16; - fi->thisblueerr[i] = rand() % 32 - 16; + fiP->thisrederr[i] = rand() % 32 - 16; + fiP->thisgreenerr[i] = rand() % 32 - 16; + fiP->thisblueerr[i] = rand() % 32 - 16; } - } - else { + } else { unsigned int i; - for( i = 0; i < cols + 2; i++ ) - fi->thisrederr[i] = fi->thisgreenerr[i] = - fi->thisblueerr[i] = 0; + for (i = 0; i < cols + 2; ++i) + fiP->thisrederr[i] = fiP->thisgreenerr[i] = + fiP->thisblueerr[i] = 0; } - return fi; + return fiP; } diff --git a/lib/pm.h b/lib/pm.h index 3850943c..8265c9ea 100644 --- a/lib/pm.h +++ b/lib/pm.h @@ -348,6 +348,9 @@ pm_check(FILE * const file, char * pm_arg0toprogname(const char arg0[]); +unsigned int +pm_randseed(void); + #ifdef __cplusplus } #endif diff --git a/lib/ppmfloyd.h b/lib/ppmfloyd.h index e16ad651..264fc0b6 100644 --- a/lib/ppmfloyd.h +++ b/lib/ppmfloyd.h @@ -15,17 +15,17 @@ struct ppm_fs_info { /* thisXerr and nextXerr are dynamically allocated arrays each of whose dimension is the width of the image plus 2 */ - long *thisrederr; - long *thisgreenerr; - long *thisblueerr; - long *nextrederr; - long *nextgreenerr; - long *nextblueerr; + long * thisrederr; + long * thisgreenerr; + long * thisblueerr; + long * nextrederr; + long * nextgreenerr; + long * nextblueerr; int lefttoright; int cols; pixval maxval; int flags; - pixel *pixrow; + pixel * pixrow; int col_end; pixval red, green, blue; }; @@ -37,7 +37,9 @@ typedef struct ppm_fs_info ppm_fs_info; #define FS_ALTERNATE 0x02 ppm_fs_info * -ppm_fs_init(int cols, pixval maxval, int flags); +ppm_fs_init(unsigned int const cols, + pixval const maxval, + unsigned int const flags); void ppm_fs_free(ppm_fs_info *fi); |