# HG changeset patch # User Matti Hamalainen # Date 1274680098 -10800 # Node ID e2b6a35bcb0c7d7b524d0653fd5231aa2caca92b # Parent 4698627de33d904efd02aa0819885074a2b5bf1b Remove usage of malloc.h; Other misc cleanups. diff -r 4698627de33d -r e2b6a35bcb0c msdos/pwplib.h --- a/msdos/pwplib.h Mon May 24 08:46:57 2010 +0300 +++ b/msdos/pwplib.h Mon May 24 08:48:18 2010 +0300 @@ -1,6 +1,5 @@ #include #include -#include #define PWPLIB_VERSION "PC-1.00" diff -r 4698627de33d -r e2b6a35bcb0c peluce/pwpdemo.h --- a/peluce/pwpdemo.h Mon May 24 08:46:57 2010 +0300 +++ b/peluce/pwpdemo.h Mon May 24 08:48:18 2010 +0300 @@ -2,7 +2,6 @@ #include #include #include -#include #include "../pwplib/pwplib.h" diff -r 4698627de33d -r e2b6a35bcb0c pwplib/X11.c --- a/pwplib/X11.c Mon May 24 08:46:57 2010 +0300 +++ b/pwplib/X11.c Mon May 24 08:48:18 2010 +0300 @@ -7,7 +7,7 @@ #include "pwplib.h" #include -#include +#include #include #include diff -r 4698627de33d -r e2b6a35bcb0c pwplib/pwplib-unix.c --- a/pwplib/pwplib-unix.c Mon May 24 08:46:57 2010 +0300 +++ b/pwplib/pwplib-unix.c Mon May 24 08:48:18 2010 +0300 @@ -281,7 +281,7 @@ if (pwplib.setup[SETUP_WANTHELP]) { - printhelp(); + pwplib_printhelp(); exit(0); } diff -r 4698627de33d -r e2b6a35bcb0c pwplib/pwplib-win.c --- a/pwplib/pwplib-win.c Mon May 24 08:46:57 2010 +0300 +++ b/pwplib/pwplib-win.c Mon May 24 08:48:18 2010 +0300 @@ -145,7 +145,7 @@ if (pwplib.setup[SETUP_WANTHELP]) { - printhelp(); + pwplib_printhelp(); exit(0); } diff -r 4698627de33d -r e2b6a35bcb0c pwplib/pwplib.h --- a/pwplib/pwplib.h Mon May 24 08:46:57 2010 +0300 +++ b/pwplib/pwplib.h Mon May 24 08:48:18 2010 +0300 @@ -47,7 +47,6 @@ #include #include -#include #include #include #include @@ -182,5 +181,6 @@ void pwplib_dump_rast_plain(); int pwp_timer_nrt(); void pwplib_getopts(); +void pwplib_printhelp(); #endif diff -r 4698627de33d -r e2b6a35bcb0c pwplib/setup.c --- a/pwplib/setup.c Mon May 24 08:46:57 2010 +0300 +++ b/pwplib/setup.c Mon May 24 08:48:18 2010 +0300 @@ -1,7 +1,7 @@ #include "config.h" #include "pwplib.h" -#define DESTRUCTORS 8 +#define MAX_DESTRUCTORS 16 /******************** random stuff *************************/ @@ -71,19 +71,23 @@ /********************* destructors, signals etc **********/ -void(*pwp_destr[DESTRUCTORS])(); +void(*pwp_destr[MAX_DESTRUCTORS + 1])(); void pwplib_regdestr(void(*func)()) { - static int curr=0; - pwp_destr[curr++]=func; - pwp_destr[curr]=NULL; + static int curr = 0; + if (curr < MAX_DESTRUCTORS) { + pwp_destr[curr++] = func; + pwp_destr[curr] = NULL; + } else { + pwpwrite("* FATAL! tried to register %d destructors where %d is max.\n", curr, MAX_DESTRUCTORS); + exit(1); + } } void pwplib_shutdown() { - int i=0; - + int i = 0; while(pwp_destr[i]!=NULL) pwp_destr[i++](); } @@ -101,14 +105,16 @@ pwplib.dump_rast= pwplib.prep_attr= pwplib.prep_rast= - pwplib_dummy; + pwplib_dummy; pwp_destr[0]=NULL; + + return 1; } /***********************************************/ -void rmarg(int*argc,char**argv,int n) +static void rmarg(int*argc,char**argv,int n) { while(n<*argc) { @@ -122,7 +128,7 @@ #define ARGC pwplib.argc #define ARGV pwplib.argv -static int getopts(optab *argin) +static void getopts(optab *argin) { int i=0; @@ -138,7 +144,7 @@ { int j=0; - int match=0,wh=-1,lev=0,m=0; + int match=0,wh=-1,lev=0; while(argin[j].name!=NULL) { @@ -268,7 +274,7 @@ NULL,0,NULL,NULL }; -void printhelp() +void pwplib_printhelp(void) { printf( "usage: %s [options] where options include:\n\n" diff -r 4698627de33d -r e2b6a35bcb0c pwplib/snd-w32.c --- a/pwplib/snd-w32.c Mon May 24 08:46:57 2010 +0300 +++ b/pwplib/snd-w32.c Mon May 24 08:48:18 2010 +0300 @@ -5,7 +5,6 @@ #include #include #include -#include #include