~ubuntu-branches/ubuntu/gutsy/kbd/gutsy

« back to all changes in this revision

Viewing changes to src/xmalloc.c

  • Committer: Package Import Robot
  • Author(s): Wartan Hachaturow
  • Date: 2002-01-30 14:01:28 UTC
  • Revision ID: package-import@ubuntu.com-20020130140128-0nb81lp1w40oz0ma
Tags: 1.06-2
* Changed Maintainer: field to wart@debian.org
* Applied patch by Ben Collins, (Closes: #110616)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Error-free versions of some libc routines */
 
2
 
 
3
#include <stdio.h>
 
4
#include <stdlib.h>
 
5
#include <string.h>
 
6
#include <sysexits.h>
 
7
#include "nls.h"
 
8
#include "xmalloc.h"
 
9
 
 
10
extern char *progname;
 
11
 
 
12
static void
 
13
nomem(void) {
 
14
        fprintf(stderr, _("%s: out of memory\n"), progname);
 
15
        exit(EX_OSERR);
 
16
}
 
17
 
 
18
void *
 
19
xmalloc(size_t sz) {
 
20
        void *p = malloc(sz);
 
21
        if (p == NULL)
 
22
                nomem();
 
23
        return p;
 
24
}
 
25
 
 
26
void *
 
27
xrealloc(void *pp, size_t sz) {
 
28
        void *p = realloc(pp, sz);
 
29
        if (p == NULL)
 
30
                nomem();
 
31
        return p;
 
32
}
 
33
 
 
34
char *
 
35
xstrdup(char *p) {
 
36
        char *q = strdup(p);
 
37
        if (q == NULL)
 
38
                nomem();
 
39
        return q;
 
40
}