Mercurial > hg > forks > pwpunix
changeset 50:e2b6a35bcb0c
Remove usage of malloc.h; Other misc cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 24 May 2010 08:48:18 +0300 |
parents | 4698627de33d |
children | 53676367d46f |
files | msdos/pwplib.h peluce/pwpdemo.h pwplib/X11.c pwplib/pwplib-unix.c pwplib/pwplib-win.c pwplib/pwplib.h pwplib/setup.c pwplib/snd-w32.c |
diffstat | 8 files changed, 22 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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 <stdio.h> #include <stdlib.h> -#include <malloc.h> #define PWPLIB_VERSION "PC-1.00"
--- 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 <stdlib.h> #include <string.h> #include <math.h> -#include <malloc.h> #include "../pwplib/pwplib.h"
--- 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 <string.h> -#include <malloc.h> +#include <stdlib.h> #include <X11/Xlib.h> #include <X11/Xutil.h>
--- 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); }
--- 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); }
--- 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 <stdio.h> #include <stdlib.h> -#include <malloc.h> #include <string.h> #include <time.h> #include <sys/time.h> @@ -182,5 +181,6 @@ void pwplib_dump_rast_plain(); int pwp_timer_nrt(); void pwplib_getopts(); +void pwplib_printhelp(); #endif
--- 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"