w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

otfcc-alloc.h
Go to the documentation of this file.
1 #ifndef CARYLL_SUPPORT_OTFCC_ALLOC_H
2 #define CARYLL_SUPPORT_OTFCC_ALLOC_H
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 #ifndef INLINE
8 #ifdef _MSC_VER
9 #define INLINE __forceinline /* use __forceinline (VC++ specific) */
10 #else
11 #define INLINE inline /* use standard inline */
12 #endif
13 #endif
14 
15 // Allocators
16 // Change this if you prefer other allocators
17 #define __caryll_malloc malloc
18 #define __caryll_calloc calloc
19 #define __caryll_realloc realloc
20 #define __caryll_free free
21 
22 static INLINE void *__caryll_allocate_dirty(size_t n, unsigned long line) {
23  if (!n) return NULL;
24  void *p = __caryll_malloc(n);
25  if (!p) {
26  fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
28  }
29  return p;
30 }
31 static INLINE void *__caryll_allocate_clean(size_t n, unsigned long line) {
32  if (!n) return NULL;
33  void *p = __caryll_calloc(n, 1);
34  if (!p) {
35  fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
37  }
38  return p;
39 }
40 static INLINE void *__caryll_reallocate(void *ptr, size_t n, unsigned long line) {
41  if (!n) {
43  return NULL;
44  }
45  if (!ptr) {
47  } else {
48  void *p = __caryll_realloc(ptr, n);
49  if (!p) {
50  fprintf(stderr, "[%ld]Out of memory(%ld bytes)\n", line, (unsigned long)n);
52  }
53  return p;
54  }
55 }
56 #ifdef __cplusplus
57 #define NEW_CLEAN_S(ptr, size) ptr = __caryll_allocate_clean((size), __LINE__)
58 #define NEW_CLEAN_1(ptr) \
59  ptr = (decltype(ptr))__caryll_allocate_clean(sizeof(decltype(*ptr)), __LINE__)
60 #define NEW_CLEAN_N(ptr, n) \
61  ptr = (decltype(ptr))__caryll_allocate_clean(sizeof(decltype(*ptr)) * (n), __LINE__)
62 #define NEW_DIRTY(ptr) \
63  ptr = (decltype(ptr))__caryll_allocate_dirty(sizeof(decltype(*ptr)), __LINE__)
64 #define NEW_DIRTY_N(ptr, n) \
65  ptr = (decltype(ptr))__caryll_allocate_dirty(sizeof(decltype(*ptr)) * (n), __LINE__)
66 #define FREE(ptr) (__caryll_free(ptr), ptr = nullptr)
67 #define DELETE(fn, ptr) (fn(ptr), ptr = nullptr)
68 #define RESIZE(ptr, n) ptr = (decltype(ptr))__caryll_reallocate(ptr, sizeof(*ptr) * (n), __LINE__)
69 #else
70 #define NEW_CLEAN_S(ptr, size) ptr = __caryll_allocate_clean((size), __LINE__)
71 #define NEW_CLEAN_1(ptr) ptr = __caryll_allocate_clean(sizeof(*ptr), __LINE__)
72 #define NEW_CLEAN_N(ptr, n) ptr = __caryll_allocate_clean(sizeof(*ptr) * (n), __LINE__)
73 #define NEW_DIRTY(ptr) ptr = __caryll_allocate_dirty(sizeof(*ptr), __LINE__)
74 #define NEW_DIRTY_N(ptr, n) ptr = __caryll_allocate_dirty(sizeof(*ptr) * (n), __LINE__)
75 #define FREE(ptr) (__caryll_free(ptr), ptr = NULL)
76 #define DELETE(fn, ptr) (fn(ptr), ptr = NULL)
77 #define RESIZE(ptr, n) ptr = __caryll_reallocate(ptr, sizeof(*ptr) * (n), __LINE__)
78 #endif
79 
80 #define __GET_MACRO_OTFCC_ALLOC_2(_1, _2, NAME, ...) NAME
81 #define NEW(...) __GET_MACRO_OTFCC_ALLOC_2(__VA_ARGS__, NEW_CLEAN_N, NEW_CLEAN_1)(__VA_ARGS__)
82 
83 #endif
#define n
Definition: t4ht.c:1290
#define EXIT_FAILURE
Definition: cdjpeg.h:169
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
void exit()
#define fprintf
Definition: mendex.h:64
#define __caryll_free
Definition: otfcc-alloc.h:20
#define __caryll_calloc
Definition: otfcc-alloc.h:18
#define INLINE
Definition: otfcc-alloc.h:11
#define __caryll_realloc
Definition: otfcc-alloc.h:19
static void * __caryll_reallocate(void *ptr, size_t n, unsigned long line)
Definition: otfcc-alloc.h:40
static void * __caryll_allocate_clean(size_t n, unsigned long line)
Definition: otfcc-alloc.h:31
#define __caryll_malloc
Definition: otfcc-alloc.h:17
static void * __caryll_allocate_dirty(size_t n, unsigned long line)
Definition: otfcc-alloc.h:22
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
Definition: bdf.c:133