<commit_before>/*
 * ppm.c
 * pud
 *
 * Copyright (c) 2014 <NAME>
 */

#include "pud_private.h"

Pud_Bool
pud_minimap_to_ppm(Pud        *pud,
                   const char *file)
{
   PUD_SANITY_CHECK(pud, PUD_OPEN_MODE_R, PUD_FALSE);

   FILE *f;
   unsigned int i, size;
   unsigned char *map;

   map = pud_minimap_bitmap_generate(pud, &size, PUD_PIXEL_FORMAT_RGBA);
   if (!map) DIE_RETURN(PUD_FALSE, "Failed to generate bitmap");

   f = fopen(file, "w");
   if (!f) DIE_RETURN(PUD_FALSE, "Failed to open [%s]", file);

   /* Write PPM header */
   fprintf(f,
           "P3\n"
           "%i %i\n"
           "255\n",
           pud->map_w, pud->map_h);

   for (i = 0; i < size; i += 4)
     {
        fprintf(f, "%i %i %i\n",
                map[i + 0],
                map[i + 1],<commit_msg>pud: fix memleak on error<commit_after>/*
 * ppm.c
 * pud
 *
 * Copyright (c) 2014 <NAME>
 */

#include "pud_private.h"

Pud_Bool
pud_minimap_to_ppm(Pud        *pud,
                   const char *file)
{
   PUD_SANITY_CHECK(pud, PUD_OPEN_MODE_R, PUD_FALSE);

   FILE *f;
   unsigned int i, size;
   unsigned char *map;

   map = pud_minimap_bitmap_generate(pud, &size, PUD_PIXEL_FORMAT_RGBA);
   if (!map) DIE_RETURN(PUD_FALSE, "Failed to generate bitmap");

   f = fopen(file, "w");
   if (!f)
     {
        free(map);
        DIE_RETURN(PUD_FALSE, "Failed to open [%s]", file);
     }

   /* Write PPM header */
   fprintf(f,
           "P3\n"
           "%i %i\n"
           "255\n",
           pud->map_w, pud->map_h);

   for (i = 0; i < size; i += 4)
     {
        fprintf(f, "%i %i %i\n",
                map[i + 0],
                map[i + 1],
{'fraction_non_alphanumeric': 0.15347432024169183, 'fraction_numerical': 0.014501510574018127, 'mean_word_length': 1.9784172661870503, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '7262070', 'n_tokens_mistral': 711, 'n_tokens_neox': 672, 'n_words': 152}