Skip to content
Snippets Groups Projects
Commit d384d160 authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

add Validator to Data

Data takes hold of the appropiate Validator.
parent 7c9a245e
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
......@@ -30,10 +31,14 @@
#include "error.h"
#include "log.h"
#include "validator.h"
#include "data.h"
static inline bool init_validator (struct SH_Data * data,
struct SH_Error * error);
static inline void init_pages (struct SH_Data * data);
struct SH_Data *
......@@ -54,6 +59,7 @@ SH_Data_new (struct SH_Error * error)
return NULL;
}
if (!init_validator (data, error)) return NULL;
init_pages (data);
if (error != NULL)
......@@ -64,11 +70,13 @@ SH_Data_new (struct SH_Error * error)
return data;
}
static inline void free_validator (struct SH_Data * data);
static inline void free_pages (struct SH_Data * data);
void
SH_Data_free (struct SH_Data * data, struct SH_Error * error)
{
free_validator (data);
free_pages (data);
free (data);
......@@ -81,6 +89,26 @@ SH_Data_free (struct SH_Data * data, struct SH_Error * error)
return;
}
static inline bool
init_validator (struct SH_Data * data, struct SH_Error * error)
{
data->validator = SH_Validator_new (error);
if (data->validator == NULL)
{
return FALSE;
}
return TRUE;
}
static inline void
free_validator (struct SH_Data * data)
{
SH_Validator_free (data->validator, NULL);
return;
}
static inline void
init_pages (struct SH_Data * data)
{
......
......@@ -29,6 +29,8 @@
#include "error.h"
#include "validator.h"
typedef unsigned int page_t;
#define PAGE_ERR 0
......@@ -44,6 +46,7 @@ struct SH_Page
struct SH_Data
{
struct SH_Validator * validator;
unsigned int page_n;
struct SH_Page * pages;
page_t last_page;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment