jweinst1
6/24/2018 - 8:56 PM

string matching object based approach in C

string matching object based approach in C

// Prototyping for match utilities for C library

typedef struct
{
	size_t len;
	size_t state; // indicates to what portion a match is made.
	char string[0];
} Pattern;

Pattern* Pattern_new(const char* string)
{
	size_t sizedStr = strlen(string);
	Pattern* newpat = malloc(sizeof(Pattern) + sizedStr);
	newpat->len = sizedStr;
	newpat->state = 0;
	return newpat;
}