~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to include/xalloc.h

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * This file may be redistributed under the terms of the
5
5
 * GNU Lesser General Public License.
6
6
 *
7
 
 * General memory allocation wrappers for malloc, realloc and calloc
 
7
 * General memory allocation wrappers for malloc, realloc, calloc and strdup
8
8
 */
9
9
 
10
10
#ifndef UTIL_LINUX_XALLOC_H
11
11
#define UTIL_LINUX_XALLOC_H
12
12
 
13
13
#include <stdlib.h>
14
 
#include <err.h>
15
14
#include <string.h>
16
15
 
17
16
#include "c.h"
52
51
 
53
52
static inline char *xstrdup(const char *str)
54
53
{
55
 
        char *ret = strdup(str);
56
 
 
57
 
        if (!ret && str)
 
54
        char *ret;
 
55
 
 
56
        if (!str)
 
57
                return NULL;
 
58
 
 
59
        ret = strdup(str);
 
60
 
 
61
        if (!ret)
58
62
                err(XALLOC_EXIT_CODE, "cannot duplicate string");
59
63
        return ret;
60
64
}