Archived
1
Fork 0
This repository has been archived on 2024-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
kilo/include/utils.h

28 lines
646 B
C
Raw Permalink Normal View History

2023-09-01 15:04:12 +00:00
#ifndef UTIL_H
#define UTIL_H
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
2023-09-08 20:32:29 +00:00
#define CLAMP(value, min, max) MIN(MAX(value, min), max)
2023-09-01 15:04:12 +00:00
#define _STRINGIZE(x) #x
#define STRINGIZE(x) _STRINGIZE(x)
2023-09-01 15:04:12 +00:00
typedef int ERRCODE;
2023-09-04 03:56:00 +00:00
#define RETURN(code) do {errcode = code; goto END;} while(0)
2023-09-01 15:04:12 +00:00
void die(const char *context);
/*****************************************************************************/
struct append_buf {
char *chars;
int n_chars;
};
struct append_buf *ab_create(void);
void ab_append(struct append_buf *ab, const char *chars, int n_chars);
void ab_free(struct append_buf *ab);
#endif // APPEND_BUF_H