~ubuntu-branches/ubuntu/hardy/nfs-utils/hardy-updates

« back to all changes in this revision

Viewing changes to support/nfs/xmalloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathaniel McCallum
  • Date: 2004-09-10 13:10:39 UTC
  • Revision ID: james.westby@ubuntu.com-20040910131039-qxfjx4pwgoz6imbv
Tags: upstream-1.0.6
ImportĀ upstreamĀ versionĀ 1.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * support/nfs/xmalloc.c
 
3
 *
 
4
 * malloc with NULL checking.
 
5
 *
 
6
 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
 
7
 */
 
8
 
 
9
#include "config.h"
 
10
 
 
11
#include <stdlib.h>
 
12
#include <string.h>
 
13
#include "xmalloc.h"
 
14
#include "xlog.h"
 
15
 
 
16
void *
 
17
xmalloc(size_t size)
 
18
{
 
19
        void    *ptr;
 
20
 
 
21
        if (!(ptr = malloc(size)))
 
22
                xlog(L_FATAL, "malloc: out of memory");
 
23
        return ptr;
 
24
}
 
25
 
 
26
void *
 
27
xrealloc(void *ptr, size_t size)
 
28
{
 
29
        if (!(ptr = realloc(ptr, size)))
 
30
                xlog(L_FATAL, "realloc: out of memory");
 
31
        return ptr;
 
32
}
 
33
 
 
34
void
 
35
xfree(void *ptr)
 
36
{
 
37
        free(ptr);
 
38
}
 
39
 
 
40
char *
 
41
xstrdup(const char *str)
 
42
{
 
43
        char    *ret;
 
44
 
 
45
        if (!(ret = strdup(str)))
 
46
                xlog(L_FATAL, "strdup: out of memory");
 
47
        return ret;
 
48
}