From 2d0181e9e07236ea28fb638c4a9eafb5896635b6 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 1 Dec 2014 13:27:13 +0100 Subject: mds-kbdc: add some test cases + fix issued with inclusion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-kbdc/raw-data.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/mds-kbdc/raw-data.c') diff --git a/src/mds-kbdc/raw-data.c b/src/mds-kbdc/raw-data.c index 3e97c9f..9f56210 100644 --- a/src/mds-kbdc/raw-data.c +++ b/src/mds-kbdc/raw-data.c @@ -46,6 +46,7 @@ void mds_kbdc_source_code_initialise(mds_kbdc_source_code_t* restrict this) this->content = NULL; this->real_content = NULL; this->line_count = 0; + this->duplicates = 0; } @@ -58,6 +59,8 @@ void mds_kbdc_source_code_destroy(mds_kbdc_source_code_t* restrict this) { if (this == NULL) return; + if (this->duplicates--) + return; free(this->lines), this->lines = NULL; free(this->real_lines), this->real_lines = NULL; free(this->content), this->content = NULL; @@ -74,6 +77,8 @@ void mds_kbdc_source_code_free(mds_kbdc_source_code_t* restrict this) { if (this == NULL) return; + if (this->duplicates--) + return; free(this->lines); free(this->real_lines); free(this->content); @@ -81,6 +86,18 @@ void mds_kbdc_source_code_free(mds_kbdc_source_code_t* restrict this) free(this); } +/** + * Create a duplicate of a `mds_kbdc_source_code_t*` + * + * @param this The `mds_kbdc_source_code_t*` + * @return `this` is returned + */ +mds_kbdc_source_code_t* mds_kbdc_source_code_dup(mds_kbdc_source_code_t* restrict this) +{ + this->duplicates++; + return this; +} + /** -- cgit v1.2.3-70-g09d2