Thu, 17 Jul 2003 19:11:30 +0200
trunk: changeset 58
Cleaned up system.mk
5 | 1 | /* |
2 | * libtu/misc.h | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
53 | 5 | * |
6 | * You may distribute and modify this library under the terms of either | |
7 | * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | |
5 | 8 | */ |
9 | ||
8 | 10 | #ifndef LIBTU_MISC_H |
11 | #define LIBTU_MISC_H | |
5 | 12 | |
13 | #include <stdlib.h> | |
14 | #include <stdio.h> | |
15 | #include <assert.h> | |
16 | #include "types.h" | |
17 | ||
18 | #define TR(X) X | |
19 | #define DUMMY_TR(X) X | |
20 | ||
21 | #define ALLOC(X) (X*)malloczero(sizeof(X)) | |
22 | #define ALLOC_N(X, N) (X*)malloczero(sizeof(X)*(N)) | |
23 | #define REALLOC_N(PTR, X, S, N) (X*)remalloczero(PTR, sizeof(X)*(S), sizeof(X)*(N)) | |
24 | ||
20 | 25 | #define FREE(X) do{if(X!=NULL)free(X);}while(0) |
5 | 26 | |
27 | extern void* malloczero(size_t size); | |
28 | extern void* remalloczero(void *ptr, size_t oldsize, size_t newsize); | |
29 | ||
30 | extern char* scopy(const char *p); | |
31 | extern char* scat(const char *p1, const char *p2); | |
32 | extern char* scatn(const char *p1, ssize_t n1, const char *p2, ssize_t n2); | |
33 | extern char* scat3(const char *p1, const char *p2, const char *p3); | |
32 | 34 | extern void stripws(char *p); |
5 | 35 | |
36 | extern const char* simple_basename(const char *name); | |
37 | ||
38 | /* I dislike fread and fwrite... */ | |
39 | extern bool readf(FILE *fd, void *buf, size_t n); | |
40 | extern bool writef(FILE *fd, const void *buf, size_t n); | |
41 | ||
8 | 42 | #endif /* LIBTU_MISC_H */ |