~ubuntu-branches/ubuntu/oneiric/bogofilter/oneiric

« back to all changes in this revision

Viewing changes to src/xmalloc.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2004-06-27 09:22:31 UTC
  • Revision ID: james.westby@ubuntu.com-20040627092231-u26smic0nhp7rl4z
Tags: upstream-0.92.0
ImportĀ upstreamĀ versionĀ 0.92.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: xmalloc.h,v 1.6 2004/02/24 18:39:16 m-a Exp $ */
 
2
 
 
3
#ifndef XMALLOC_H
 
4
#define XMALLOC_H
 
5
 
 
6
#include <stddef.h>
 
7
#include <stdlib.h>
 
8
 
 
9
#ifdef  BF_MALLOC
 
10
/* special defines for xmalloc.c, xcalloc.c, etc */
 
11
#ifndef ENABLE_MEMDEBUG
 
12
  #define bf_malloc  malloc
 
13
  #define bf_calloc  calloc
 
14
  #define bf_realloc realloc
 
15
  #define bf_free    free
 
16
#else
 
17
  #include "memdebug.h"
 
18
#endif
 
19
#endif
 
20
 
 
21
/*@noreturn@*/
 
22
/** print out of memory error and exit program */
 
23
void xmem_error(const char *)
 
24
#ifdef __GNUC__
 
25
 __attribute__((noreturn))
 
26
#endif
 
27
   ;
 
28
 
 
29
/*@noreturn@*/
 
30
/** print string too long error and exit program */
 
31
void xmem_toolong(const char *)
 
32
#ifdef __GNUC__
 
33
 __attribute__((noreturn))
 
34
#endif
 
35
   ;
 
36
 
 
37
/*@only@*/ /*@out@*/ /*@notnull@*/
 
38
/** allocate \a size bytes of memory, exit program on allocation failure
 
39
 */
 
40
void *xmalloc(size_t size);
 
41
 
 
42
/** free memory area at \a ptr if ptr is non-NULL, do nothing if \a ptr
 
43
 * is NULL */
 
44
void xfree(/*@only@*/ /*@null@*/ void *ptr);
 
45
 
 
46
/** allocate and clear \a nmemb blocks of \a size bytes of memory, exit
 
47
 * program on allocation failure */
 
48
/*@only@*/ /*@out@*/ /*@notnull@*/
 
49
void *xcalloc(size_t nmemb, size_t size);
 
50
 
 
51
/** reallocate \a size bytes of memory and initialize it with the
 
52
 * first bytes of the shorter area (old in \a ptr vs. newly allocated),
 
53
 * exit program on allocation failure */
 
54
/*@only@*/ /*@out@*/ /*@notnull@*/
 
55
void *xrealloc(/*@only@*/ void *ptr, size_t size);
 
56
 
 
57
#endif