include/libtu/misc.h

Sat, 01 Jul 2000 14:18:56 +0200

author
tuomov
date
Sat, 01 Jul 2000 14:18:56 +0200
changeset 16
f597c8f0bcc9
parent 9
55e7f2ff6021
child 20
3f11f764772a
permissions
-rw-r--r--

trunk: changeset 19
Use POSIX_SOURCE

5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
1 /*
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
2 * libtu/misc.h
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
3 *
9
55e7f2ff6021 trunk: changeset 12
tuomov
parents: 8
diff changeset
4 * Copyright (c) Tuomo Valkonen 1999-2000.
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
5 * See the included file LICENSE for details.
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
6 */
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
7
8
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
8 #ifndef LIBTU_MISC_H
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
9 #define LIBTU_MISC_H
5
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
10
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
11 #include <stdlib.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
12 #include <stdio.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
13 #include <assert.h>
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
14 #include "types.h"
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
15
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
16 #define TR(X) X
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
17 #define DUMMY_TR(X) X
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
18
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
19 #define ALLOC(X) (X*)malloczero(sizeof(X))
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
20 #define ALLOC_N(X, N) (X*)malloczero(sizeof(X)*(N))
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
21 #define REALLOC_N(PTR, X, S, N) (X*)remalloczero(PTR, sizeof(X)*(S), sizeof(X)*(N))
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
22
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
23 #define FREE(X) ({if(X!=NULL) free(X);})
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
24
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
25 extern void* malloczero(size_t size);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
26 extern void* remalloczero(void *ptr, size_t oldsize, size_t newsize);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
27
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
28 extern char* scopy(const char *p);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
29 extern char* scat(const char *p1, const char *p2);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
30 extern char* scatn(const char *p1, ssize_t n1, const char *p2, ssize_t n2);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
31 extern char* scat3(const char *p1, const char *p2, const char *p3);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
32
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
33 extern const char* simple_basename(const char *name);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
34
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
35 /* I dislike fread and fwrite... */
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
36 extern bool readf(FILE *fd, void *buf, size_t n);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
37 extern bool writef(FILE *fd, const void *buf, size_t n);
f878a9ffa3e0 trunk: changeset 8
tuomov
parents:
diff changeset
38
8
c1994196683f trunk: changeset 11
tuomov
parents: 5
diff changeset
39 #endif /* LIBTU_MISC_H */

mercurial