aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/raw-data.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-12-01 13:27:13 +0100
committerMattias Andrée <maandree@operamail.com>2014-12-01 13:27:13 +0100
commit2d0181e9e07236ea28fb638c4a9eafb5896635b6 (patch)
tree2cd560e7bd8fa5960a06e4fade81fd57b6dc581f /src/mds-kbdc/raw-data.c
parentm (diff)
downloadmds-2d0181e9e07236ea28fb638c4a9eafb5896635b6.tar.gz
mds-2d0181e9e07236ea28fb638c4a9eafb5896635b6.tar.bz2
mds-2d0181e9e07236ea28fb638c4a9eafb5896635b6.tar.xz
mds-kbdc: add some test cases + fix issued with inclusion
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-kbdc/raw-data.c17
1 files changed, 17 insertions, 0 deletions
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;
+}
+
/**