File: util.h

package info (click to toggle)
parchive 1.1-4.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260 kB
  • ctags: 341
  • sloc: ansic: 3,895; makefile: 55
file content (16 lines) | stat: -rw-r--r-- 500 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*\
|*| Some utility macro's
|*|
|*|  Copyright (C) 2001  Willem Monsuwe (willem@stack.nl)
\*/
#ifndef UTIL_H
#define UTIL_H

#define HEXDIGIT(i) (((i) + (((i) < 0xA) ? '0' : ('a' - 0xA))))

#define NEW(ptr, size) ((ptr) = (malloc(sizeof(*(ptr)) * (size))))
#define CNEW(ptr, size) ((ptr) = (calloc(sizeof(*(ptr)), (size))))
#define RENEW(ptr, size) ((ptr) = (realloc((ptr), sizeof(*(ptr)) * (size))))
#define COPY(tgt, src, nel) (memcpy((tgt), (src), ((nel) * sizeof(*(tgt)))))

#endif /* UTIL_H */