From 8cb463adec1215c8e70055fc7da0cd5a54270067 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 17 Oct 2009 12:17:16 +0000 Subject: [PATCH] Move alloc.c protos into alloc.h --- Makefile.in | 12 ++++++------ alloc.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ getline.c | 3 +-- sudo.h | 11 +---------- sudoreplay.c | 5 +---- 5 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 alloc.h diff --git a/Makefile.in b/Makefile.in index cc1f1b1e5..46a549d9b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -120,7 +120,7 @@ AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \ auth/secureware.c auth/securid.c auth/securid5.c auth/sia.c \ auth/sudo_auth.c -HDRS = bsm_audit.h compat.h def_data.h defaults.h error.h ins_2001.h \ +HDRS = alloc.h bsm_audit.h compat.h def_data.h defaults.h error.h ins_2001.h \ ins_classic.h ins_csops.h ins_goons.h insults.h interfaces.h lbuf.h \ list.h logging.h missing.h nonunix.h redblack.h parse.h sudo.h \ sudo_nss.h gram.h auth/sudo_auth.h emul/charclass.h emul/fnmatch.h \ @@ -168,10 +168,10 @@ BINFILES= ChangeLog HISTORY LICENSE README TROUBLESHOOTING \ BINSPECIAL= INSTALL.binary Makefile.binary.in libtool -SUDODEP = $(srcdir)/sudo.h $(srcdir)/compat.h $(srcdir)/defaults.h \ - $(srcdir)/error.h $(srcdir)/list.h $(srcdir)/logging.h \ - $(srcdir)/missing.h $(srcdir)/sudo_nss.h $(devdir)/def_data.h \ - pathnames.h config.h +SUDODEP = $(srcdir)/sudo.h $(srcdir)/alloc.h $(srcdir)/compat.h \ + $(srcdir)/defaults.h $(srcdir)/error.h $(srcdir)/list.h \ + $(srcdir)/logging.h $(srcdir)/missing.h $(srcdir)/sudo_nss.h \ + $(devdir)/def_data.h pathnames.h config.h AUTHDEP = $(SUDODEP) $(authdir)/sudo_auth.h @@ -336,7 +336,7 @@ selinux.o: $(srcdir)/selinux.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/selinux.c sudo.o: $(srcdir)/sudo.c $(SUDODEP) sudo_usage.h $(srcdir)/interfaces.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudo.c -sudoreplay.o: $(srcdir)/sudoreplay.c $(srcdir)/compat.h $(srcdir)/error.h $(srcdir)/missing.h config.h +sudoreplay.o: $(srcdir)/sudoreplay.c $(srcdir)/alloc.h $(srcdir)/compat.h $(srcdir)/error.h $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudoreplay.c sudo_edit.o: $(srcdir)/sudo_edit.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudo_edit.c diff --git a/alloc.h b/alloc.h new file mode 100644 index 000000000..a92ba71c3 --- /dev/null +++ b/alloc.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2009 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $Sudo$ + */ + +#ifndef _SUDO_ALLOC_H +#define _SUDO_ALLOC_H + +#ifdef __STDC__ +# include +int easprintf(char **, const char *, ...) __printflike(2, 3); +int evasprintf(char **, const char *, va_list) __printflike(2, 0); +void efree(void *); +void *emalloc(size_t); +void *emalloc2(size_t, size_t); +void *erealloc(void *, size_t); +void *erealloc3(void *, size_t, size_t); +char *estrdup(const char *); +#else +# include +int easprintf(); +int evasprintf(); +void efree(); +void *emalloc(); +void *emalloc2(); +void *erealloc(); +void *erealloc3(); +char *estrdup(); +#endif /* __STDC__ */ + +#endif /* _SUDO_ALLOC_H */ diff --git a/getline.c b/getline.c index 5ebbd7a22..705dd5f67 100644 --- a/getline.c +++ b/getline.c @@ -37,13 +37,12 @@ #include #include "compat.h" +#include "alloc.h" #ifndef LINE_MAX # define LINE_MAX 2048 #endif -extern void *erealloc __P((void *, size_t)); - #ifdef HAVE_FGETLN ssize_t getline(bufp, bufsizep, fp) diff --git a/sudo.h b/sudo.h index c08ba16fc..e3f56cfd6 100644 --- a/sudo.h +++ b/sudo.h @@ -27,6 +27,7 @@ #include #include #include "compat.h" +#include "alloc.h" #include "defaults.h" #include "error.h" #include "list.h" @@ -231,16 +232,6 @@ void sia_attempt_auth __P((void)); void pam_attempt_auth __P((void)); int yyparse __P((void)); void pass_warn __P((FILE *)); -void *emalloc __P((size_t)); -void *emalloc2 __P((size_t, size_t)); -void *erealloc __P((void *, size_t)); -void *erealloc3 __P((void *, size_t, size_t)); -char *estrdup __P((const char *)); -int easprintf __P((char **, const char *, ...)) - __printflike(2, 3); -int evasprintf __P((char **, const char *, va_list)) - __printflike(2, 0); -void efree __P((void *)); void dump_defaults __P((void)); void dump_auth_methods __P((void)); void init_envtables __P((void)); diff --git a/sudoreplay.c b/sudoreplay.c index 3c595d26c..e99302361 100644 --- a/sudoreplay.c +++ b/sudoreplay.c @@ -81,6 +81,7 @@ #include #include "compat.h" +#include "alloc.h" #include "error.h" #include "missing.h" @@ -148,10 +149,6 @@ struct search_node { static struct search_node *node_stack[32]; static int stack_top; -extern void *emalloc __P((size_t)); -extern void *emalloc2 __P((size_t, size_t)); -extern void *erealloc __P((void *, size_t)); -extern void efree __P((void *)); extern time_t get_date __P((char *)); extern char *get_timestr __P((time_t, int)); extern int term_cbreak __P((int)); -- 2.40.0