diff -r 000000000000 -r 86b7f6f9c5c0 include/misc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/misc.h Tue Feb 15 18:57:52 2005 +0100 @@ -0,0 +1,41 @@ +/* + * libtu/misc.h + * + * Copyright (c) Tuomo Valkonen 1999-2000. + * + * This file is distributed under the terms of the "Artistic License". + * See the included file LICENSE for details. + */ + +#ifndef __LIBTU_MISC_H +#define __LIBTU_MISC_H + +#include +#include +#include +#include +#include "types.h" + +#define TR(X) X +#define DUMMY_TR(X) X + +#define ALLOC(X) (X*)malloczero(sizeof(X)) +#define ALLOC_N(X, N) (X*)malloczero(sizeof(X)*(N)) +#define REALLOC_N(PTR, X, S, N) (X*)remalloczero(PTR, sizeof(X)*(S), sizeof(X)*(N)) + +#define FREE(X) ({if(X!=NULL) free(X);}) + +extern void* malloczero(int size); +extern void* remalloczero(void *ptr, int oldsize, int newsize); + +extern char* scopy(const char *p); +extern char* scat(const char *p1, const char *p2); +extern char* scat3(const char *p1, const char *p2, const char *p3); + +extern const char* simple_basename(const char *name); + +/* I dislike fread and fwrite... */ +extern bool readf(FILE *fd, void *buf, size_t n); +extern bool writef(FILE *fd, const void *buf, size_t n); + +#endif /* __LIBTU_MISC_H */