<commit_before>#include <errno.h>
#include "zsfunctions.h"

#ifdef _WITH_SS5
#include "constants.ss5.h"
#else
#include "constants.h"
#endif

#include "convert.h"

struct GROUP {
	char           *name;
	gid_t		id;
};

struct USER {
	char           *name;
	uid_t		id;
};

struct dirent **dirlist;
struct dirent **dirlistp;
unsigned int	direntries = 0;
unsigned int	direntriesp = 0;
int		num_groups = 0, num_users = 0;
struct USER   **user;
struct GROUP  **group;

void 
d_log(char *fmt,...)
{
#if ( debug_mode == TRUE )
	time_t		timenow;
	FILE           *file;
	va_list		ap;
	char           *debugname;
#if ( debug_altlog == TRUE )
	char           *debugpath = 0;
#endif
#endif

	if (fmt == NULL)
		return;
#if ( debug_mode == TRUE )
	va_start(ap, fmt);
	timenow = time(NULL);

#if ( debug_altlog == TRUE )
	debugpath = malloc(PATH_MAX);
	getcwd(debugpath, PATH_MAX);
	debugname = malloc(PATH_MAX);
	sprintf(debugname, "%s/%s/.debug", storage, debugpath);
	free(debugpath);
#else
	debugname = malloc(strlen(".debug") + 2);
	sprintf(debugname, ".debug");
#endif

	if ((file = fopen(debugname, "a+"))) {
		fprintf(file, "%.24s - ", ctime(&timenow));
		vfprintf(file, fmt, ap);
		fclose(file);
	}
	chmod(debugname, 0666);
	free(debugname);
#endif
	return;
}

void 
create_missing(char *f, short int l)
{
	char           *fname;
<commit_msg>rewrote d_log to not use malloc/free<commit_after>#include <errno.h>
#include "zsfunctions.h"

#ifdef _WITH_SS5
#include "constants.ss5.h"
#else
#include "constants.h"
#endif

#include "convert.h"

struct GROUP {
	char           *name;
	gid_t		id;
};

struct USER {
	char           *name;
	uid_t		id;
};

struct dirent **dirlist;
struct dirent **dirlistp;
unsigned int	direntries = 0;
unsigned int	direntriesp = 0;
int		num_groups = 0, num_users = 0;
struct USER   **user;
struct GROUP  **group;

void 
d_log(char *fmt,...)
{
#if ( debug_mode == TRUE )
	time_t		timenow;
	FILE           *file;
	va_list		ap;
	char		debugname[] = ".debug";
#if ( debug_altlog == TRUE )
	//char           *debugpath = 0;
	char		debugpath[PATH_MAX];
	char		debugname[PATH_MAX];
#endif
#endif

	if (fmt == NULL)
		return;
#if ( debug_mode == TRUE )
	va_start(ap, fmt);
	timenow = time(NULL);

#if ( debug_altlog == TRUE )
	//debugpath = malloc(PATH_MAX);
	getcwd(debugpath, PATH_MAX);
	//debugname = malloc(PATH_MAX);
	sprintf(debugname, "%s/%s/.debug", storage, debugpath);
	//free(debugpath);
#else
	//debugname = malloc(strlen(".debug") + 2);
	//sprintf(debugname, ".debug");
#endif

	if ((file = fopen(debugname, "a+"))) {
		fprintf(file, "%.24s - ", ctime(&timenow));
		vfprintf(file, fmt, ap);
		fclose(file);
	}
	chmod(debugname, 0666);
	//free(debugname);
#endif
	return;
}

void 
create_missing(char *f, short int l)
{
	char           *fname;

{'fraction_non_alphanumeric': 0.16052060737527116, 'fraction_numerical': 0.01012292118582791, 'mean_word_length': 3.5435139573070606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4093425', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1121, 'n_words': 268}