GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
shoes / shoes / internal.h
100644 64 lines (50 sloc) 1.482 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// shoes/internal.h
// Debugging and allocation functions within Shoes.
//
 
#ifndef SHOES_INTERNAL_H
#define SHOES_INTERNAL_H
 
#define SHOE_REALLOC_N(V, T, N) (V)=(T *)realloc((char*)(V), sizeof(T)*(N))
#define SHOE_ALLOC_N(T, N) (T *)malloc(sizeof(T) * N)
#define SHOE_ALLOC(T) (T *)malloc(sizeof(T))
#define SHOE_FREE(T) free((void*)T)
 
#define SHOE_MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
#define SHOE_MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
#define SHOE_MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
#define SHOE_MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
 
#ifndef min
#define min(a, b) ((a) <= (b) ? (a) : (b))
#endif
 
#ifndef max
#define max(a, b) ((a) >= (b) ? (a) : (b))
#endif
 
#ifdef SHOES_WIN32
 
void odprintf(const char *format, ...);
static inline void odignore(const char *format, ...) {}
int shoes_snprintf(char* str, size_t size, const char* format, ...);
#define PUTS odprintf
 
#ifdef DEBUG
#define INFO PUTS
#else
#define INFO odignore
#endif
#define WARN PUTS
#define QUIT(msg) \
  if (code == SHOES_OK) code = SHOES_FAIL; \
  PUTS(msg); \
  goto quit
 
#else
 
#define shoes_snprintf snprintf
 
#define PUTS printf
#ifdef DEBUG
 
#define INFO(f, s...) PUTS(f, ## s)
#else
#define INFO(f, s...)
#endif
#define WARN(f, s...) PUTS(f, ## s)
#define QUIT(f, s...) \
  if (code == SHOES_OK) code = SHOES_FAIL; \
  PUTS(f, ## s); \
  goto quit
#endif
 
#endif