File: memutil.h

package info (click to toggle)
tcng 10b-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,632 kB
  • ctags: 2,515
  • sloc: ansic: 19,038; pascal: 4,640; yacc: 2,619; sh: 1,908; perl: 1,546; lex: 772; makefile: 755
file content (36 lines) | stat: -rw-r--r-- 752 bytes parent folder | download | duplicates (5)
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
29
30
31
32
33
34
35
36
/*
 * memutil.h - Utility functions for dynamic memory allocation
 *
 * Written 2001,2002 by Werner Almesberger
 * Copyright 2001 EPFL-ICA
 * Copyright 2001,2002 Bivio Networks, Network Robots
 */


#ifndef MEMUTIL_H
#define MEMUTIL_H

#include <sys/types.h>


/* ----- Malloc wrappers --------------------------------------------------- */


#define alloc_t(T) ((T *) alloc(sizeof(T)))

void *alloc(size_t size);
char *stralloc(const char *s);


/* ----- "Safe" sprintf ---------------------------------------------------- */


int log_8(unsigned long value);
int log_10(unsigned long value);
int log_16(unsigned long value);

char *alloc_sprintf(const char *fmt,...);

/* Like asprintf, but has defined behaviour on ENOMEM */

#endif /* MEMUTIL_H */