<commit_before>#ifndef __NENGO_COMMON_H__
#define __NENGO_COMMON_H__

/*! \def MALLOC_FAIL_NULL
 *  Will malloc \a SIZE and save the returned pointer in \a VAR.  Should the
 *  malloc fail \a DESC will be printed to IO_BUF and NULL will be returned
 *  from the given function.
 */
#define MALLOC_FAIL_NULL(VAR, SIZE, DESC) \
do { VAR = spin1_malloc(SIZE); \
  if (VAR == NULL) { \
    io_printf(IO_BUF, DESC " Failed to malloc " #VAR " (%d bytes)\n", SIZE); \
    return NULL; \
} else { \
  io_printf(IO_BUF, DESC " Malloc " #VAR " (%d bytes)\n", SIZE); \
}} while (0)


/*! \def MALLOC_FAIL_FALSE
 *  Will malloc \a SIZE and save the returned pointer in \a VAR.  Should the
 *  malloc fail \a DESC will be printed to IO_BUF and FALSE will be returned
 *  from the given function.
 */
#define MALLOC_FAIL_FALSE(VAR, SIZE, DESC) \
do { VAR = spin1_malloc(SIZE); \
  if (VAR == NULL) { \
    io_printf(IO_BUF, DESC " Failed to malloc " #VAR " (%d bytes)\n", SIZE); \
    return false; \
} else { \
  io_printf(IO_BUF, DESC " Malloc " #VAR " (%d bytes)\n", SIZE); \
}} while(0)

#endif<commit_msg>Neaten the MALLOC_FAIL_* definitions to reduce duplication.<commit_after>#ifndef __NENGO_COMMON_H__
#define __NENGO_COMMON_H__

/** \def __MALLOC_FAIL
 * Will malloc \a SIZE and save the return pointer in \a VAR.  Should the
 * malloc fail \a DESC and an explanation will be stored in IO_BUF and
 * \a VAL will be returned on behalf of the calling function.
 */
#define __MALLOC_FAIL(VAR, SIZE, DESC, VAL) \
do { \
  if ((SIZE) == 0) { \
    VAR = NULL; \
  } else { \
    VAR = spin1_malloc(SIZE); \
    if (VAR == NULL) { \
      io_printf(IO_BUF, DESC " Failed to malloc " #VAR " (%d bytes)\n", \
                (SIZE)); \
      return VAL; \
    } else { \
      io_printf(IO_BUF, DESC " Malloc " #VAR " (%d bytes)\n", (SIZE)); \
    } \
  } \
} while (0)

/*! \def MALLOC_FAIL_NULL
 *  Will malloc \a SIZE and save the returned pointer in \a VAR.  Should the
 *  malloc fail \a DESC will be printed to IO_BUF and NULL will be returned
 *  on behalf of the calling function.
 */
#define MALLOC_FAIL_NULL(VAR, SIZE, DESC) \
  __MALLOC_FAIL(VAR, SIZE, DESC, NULL)

/*! \def MALLOC_FAIL_FALSE
 *  Will malloc \a SIZE and save the returned pointer in \a VAR.  Should the
 *  malloc fail \a DESC will be printed to IO_BUF and FALSE will be returned
 *  on behalf of the calling function.
 */
#define MALLOC_FAIL_FALSE(VAR, SIZE, DESC) \
  __MALLOC_FAIL(VAR, SIZE, DESC, false)

#endif
{'fraction_non_alphanumeric': 0.1217741935483871, 'fraction_numerical': 0.00282258064516129, 'mean_word_length': 2.9887459807073955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2546874', 'n_tokens_mistral': 901, 'n_tokens_neox': 864, 'n_words': 310}