| 191 | |
| 192 | template <typename T> |
| 193 | void gpc_malloc(T *&p, int b, char *s) { // NOLINT |
| 194 | if (b > 0) { |
| 195 | p = reinterpret_cast<T *>(malloc(b)); |
| 196 | |
| 197 | if (!p) { |
| 198 | fprintf(stderr, "gpc malloc failure: %s\n", s); |
| 199 | exit(0); |
| 200 | } |
| 201 | } else { |
| 202 | p = NULL; |
| 203 | } |
| 204 | } |
| 205 | template <typename T> |
| 206 | void gpc_free(T *&p) { // NOLINT |
| 207 | if (p) { |