summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-02-01 21:13:25 +0000
committerArthur de Jong <arthur@arthurdejong.org>2007-02-01 21:13:25 +0000
commit20481e8d3b817d2f9c560aaf4a56581325ad1572 (patch)
tree2c4ede05db9ab09e93cbc9f00953830766deaf13
parent5fc5a1bf89cd6c76be869fc09eb83197efdd2335 (diff)
get rid of xmalloc.[ch]
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@230 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/Makefile.am1
-rw-r--r--nslcd/log.c10
-rw-r--r--nslcd/xmalloc.c59
-rw-r--r--nslcd/xmalloc.h36
4 files changed, 8 insertions, 98 deletions
diff --git a/nslcd/Makefile.am b/nslcd/Makefile.am
index 3f1ffa0..4da31f5 100644
--- a/nslcd/Makefile.am
+++ b/nslcd/Makefile.am
@@ -23,7 +23,6 @@ AM_CFLAGS = -pthread
nslcd_SOURCES = nslcd.c ../nslcd.h ../nslcd-common.h \
log.c log.h \
- xmalloc.c xmalloc.h \
common.c common.h \
resolve.c resolve.h \
ldap-schema.c ldap-schema.h \
diff --git a/nslcd/log.c b/nslcd/log.c
index 0420a45..d5f89de 100644
--- a/nslcd/log.c
+++ b/nslcd/log.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <stdio.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <syslog.h>
@@ -31,7 +32,6 @@
#include <string.h>
#include "log.h"
-#include "xmalloc.h"
/* set the logname */
@@ -63,7 +63,13 @@ static void log_addlogging_fp(FILE *fp,int loglevel)
{
struct cvsd_log *tmp,*lst;
/* create new logstruct */
- tmp=(struct cvsd_log *)xmalloc(sizeof(struct cvsd_log));
+ tmp=(struct cvsd_log *)malloc(sizeof(struct cvsd_log));
+ if (tmp==NULL)
+ {
+ fprintf(stderr,"malloc() failed: %s",strerror(errno));
+ /* since this is done during initialisation it's best to bail out */
+ exit(1);
+ }
tmp->fp=fp;
tmp->loglevel=loglevel;
tmp->next=NULL;
diff --git a/nslcd/xmalloc.c b/nslcd/xmalloc.c
deleted file mode 100644
index 83c346c..0000000
--- a/nslcd/xmalloc.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- xmalloc.c - malloc wrapper
-
- Copyright (C) 2002, 2003, 2006 Arthur de Jong
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA
-*/
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "xmalloc.h"
-#include "log.h"
-
-
-/* malloc wrapper */
-void *xmalloc(size_t size)
-{
- void *tmp;
- if ((tmp=malloc(size))==NULL)
- {
- log_log(LOG_CRIT,"malloc() failed");
- exit(1);
- }
- return tmp;
-}
-
-
-/* strdup wrapper */
-char *xstrdup(const char *s)
-{
- char *tmp;
- int l;
- if (s==NULL)
- {
- log_log(LOG_CRIT,"xstrdup() called with NULL");
- exit(1);
- }
- l=strlen(s);
- tmp=(char *)xmalloc((l+1)*sizeof(char));
- strncpy(tmp,s,l);
- tmp[l]='\0';
- return tmp;
-}
diff --git a/nslcd/xmalloc.h b/nslcd/xmalloc.h
deleted file mode 100644
index 68330e1..0000000
--- a/nslcd/xmalloc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- xmalloc.h - malloc wrapper
-
- Copyright (C) 2002 Arthur de Jong
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA
-*/
-
-#ifndef _XMALLOC_H
-#define _XMALLOC_H 1
-
-#include <stdlib.h>
-
-/* malloc wrapper */
-void *xmalloc(size_t size);
-
-/* allocate size for a specific type */
-#define xxmalloc(type,count) (type *)xmalloc(sizeof(type)*(count))
-
-/* strdup wrapper */
-char *xstrdup(const char *s);
-
-#endif /* not _XMALLOC_H */