aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/raw-data.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mds-kbdc/raw-data.c')
-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;
+}
+
/**