<commit_before>#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef enum { INT, FLOAT, CHAR, STRING } property_type;

typedef struct _property {
	char name;
	property_type type;
	
	int i_value;
	float f_value;
	char c_value;
	char *s_value;
} property;


static property *properties = NULL;
static int property_count = 0;


int getEqualsSignPosition(char *string) {

	int esp = -1;
	if(string == NULL)
		return -1;

	int j;	
	for(j=0;string[j]!='\0'&&string[j]!='\n'; j++) {
		if(string[j] == '=') {
			esp = j;
			break;
		}
	}
	return esp;
}

char * getPropertyName(char *line) {


	int esp = getEqualsSignPosition(line);

	if(esp==-1 || esp==0) //does not exist or key is empty
		return NULL;

	int i;
	char *pn = malloc(esp+1);
	for(i=0; i<esp; i++) {
		pn[i]=line[i];
	}
	pn[i]='\0';
	
	return pn;
}

char * getPropertyValue(char *line) {
	
	int esp = getEqualsSignPosition(line);
	int lineLength = strlen(line);

	if(esp==-1 || esp==0 || esp==lineLength+1) //does not exist or key is empty
		return NULL;

	int i;
	char *pv = malloc(lineLength-esp-1);
	for(i=esp+1; i<lineLength-1; i++) {
		pv[i-(esp+1)]=line[i];
	}
	pv[i]='\0';
	
	return pv;
}

char* vc_read_file() {

	FILE *file = fopen(CONFIG_FILE_NAME, "r");
	size_t max_line_length = DEFAULT_MAX_LINE_LENGTH;
	char * line = (char*) malloc(max_line_length * sizeof(char));
	ssize_t read;

	int max_property_count = DEFAULT_MAX_PROPERTY_COUNT;
	properties = (property*) malloc(max_property_count * sizeof(property));
<commit_msg>Replace coping using for loops with memcpy<commit_after>#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef enum { INT, FLOAT, CHAR, STRING } property_type;

typedef struct _property {
	char name;
	property_type type;
	
	int i_value;
	float f_value;
	char c_value;
	char *s_value;
} property;


static property *properties = NULL;
static int property_count = 0;


int getEqualsSignPosition(char *string) {

	int esp = -1;
	if(string == NULL)
		return -1;

	int j;	
	for(j=0;string[j]!='\0'&&string[j]!='\n'; j++) {
		if(string[j] == '=') {
			esp = j;
			break;
		}
	}
	return esp;
}

char * getPropertyName(char *line) {


	int esp = getEqualsSignPosition(line);

	if(esp==-1 || esp==0) //does not exist or key is empty
		return NULL;

	int i;
	char *pn = malloc(esp+1);
	memcpy(pn,line,esp);
	pn[esp]='\0';
	
	return pn;
}

char * getPropertyValue(char *line) {
	
	int esp = getEqualsSignPosition(line);
	int lineLength = strlen(line);

	if(esp==-1 || esp==0 || esp==lineLength+1) //does not exist or key is empty
		return NULL;

	int i;
	char *pv = malloc(lineLength-esp-1);
	memcpy(pv,line+esp+1,lineLength-esp-2);
	pv[lineLength-esp-2]='\0';
	
	return pv;
}

char* vc_read_file() {

	FILE *file = fopen(CONFIG_FILE_NAME, "r");
	size_t max_line_length = DEFAULT_MAX_LINE_LENGTH;
	char * line = (char*) malloc(max_line_length * sizeof(char));
	ssize_t read;

	int max_property_count = DEFAULT_MAX_PROPERTY_COUNT;
	properties = (property*) malloc(max_property_count * sizeof(property));

{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.011475409836065573, 'mean_word_length': 4.306086956521739, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3647567', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1195, 'n_words': 288}