<commit_before>/*
 * all macros, definitions and small functions which
 * not fit to other header and often used are here
 *
 *  Created on: Jun 17, 2012
 *      Author: d'b
 */

#ifndef TOOLS_H_
#define TOOLS_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include "src/service_runtime/include/sys/errno.h"

#define KEYWORD_SIZE_MAX 256
#define BIG_ENOUGH_SPACE 65536 /* ..size of the biggest temporary variable */

/* check condition 'cond' if false aborts zerovm with message 'msg' */
/*
 * check condition 'cond' if false aborts zerovm with message 'msg'
 * WARNING: must not be defined as an empty macro! it used to run functions
 */
#define COND_ABORT(cond, msg) if(cond) {fprintf(stderr, "%s\n", msg); exit(1);}

/* malloc and check. if allocation failed abort with message 'msg' */
static inline void *my_malloc(size_t size, const char *msg)
{
  void *ptr = malloc(size);
  COND_ABORT(ptr == NULL, msg);
  return ptr;
}
#define MALLOC(size, msg) my_malloc((size), (msg))

/* safe memcpy(). NULL can be used. return NULL if copy failed */
static inline void *my_memcpy(void *dst, void const *src, size_t size)
{
  return (dst == NULL || src == NULL) ? NULL : memcpy(dst, src, size);<commit_msg>fix: missed header<commit_after>/*
 * all macros, definitions and small functions which
 * not fit to other header and often used are here
 *
 *  Created on: Jun 17, 2012
 *      Author: d'b
 */

#ifndef TOOLS_H_
#define TOOLS_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include "src/service_runtime/include/sys/errno.h"

#define KEYWORD_SIZE_MAX 256
#define BIG_ENOUGH_SPACE 65536 /* ..size of the biggest temporary variable */

/* check condition 'cond' if false aborts zerovm with message 'msg' */
/*
 * check condition 'cond' if false aborts zerovm with message 'msg'
 * WARNING: must not be defined as an empty macro! it used to run functions
 */
#define COND_ABORT(cond, msg) if(cond) {fprintf(stderr, "%s\n", msg); exit(1);}

/* malloc and check. if allocation failed abort with message 'msg' */
static inline void *my_malloc(size_t size, const char *msg)
{
  void *ptr = malloc(size);
  COND_ABORT(ptr == NULL, msg);
  return ptr;
}
#define MALLOC(size, msg) my_malloc((size), (msg))

/* safe memcpy(). NULL can be used. return NULL if copy failed */
static inline void *my_memcpy(void *dst, void const *src, size_t size)
{
  return (dst == NULL || src == NULL) ? NULL : memcpy(dst, src, size);
{'fraction_non_alphanumeric': 0.13076014178810555, 'fraction_numerical': 0.011815675462780622, 'mean_word_length': 4.215605749486653, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '1155138', 'n_tokens_mistral': 890, 'n_tokens_neox': 857, 'n_words': 315}