File: altmalloc.h

package info (click to toggle)
libmoe 1.5.2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 6,772 kB
  • ctags: 267,598
  • sloc: ansic: 478,484; perl: 2,308; makefile: 199; sh: 22
file content (28 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef ALTMALLOC_H
#define ALTMALLOC_H

#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>

typedef void *(*alt_allocater_t)(size_t);
typedef void *(*alt_reallocater_t)(void *, size_t);
typedef void (*alt_freer_t)(void *);

extern alt_allocater_t alt_malloc;
extern alt_allocater_t alt_malloc_atomic;
extern alt_reallocater_t alt_realloc;
extern alt_freer_t alt_free;

extern alt_allocater_t alt_set_allocater(alt_allocater_t new);
#define alt_call_malloc(size) (alt_malloc ? alt_malloc((size)) : NULL)
extern alt_allocater_t alt_set_atomic_allocater(alt_allocater_t new);
#define alt_call_malloc_atomic(size) (alt_malloc_atomic ? alt_malloc_atomic((size)) : NULL)
extern alt_reallocater_t alt_set_reallocater(alt_reallocater_t new);
#define alt_call_realloc(p, size) (alt_realloc ? alt_realloc((p), (size)) : NULL)
extern alt_freer_t alt_set_freer(alt_freer_t new);
#define alt_call_free(garbage) do { if (alt_free) alt_free((garbage)); } while (0)
#define alt_has_free_p() (!!alt_free)
extern int alt_malloc_vs(ptrdiff_t *p_size, ptrdiff_t n, ptrdiff_t limit, ...);

#endif