From 805704bd59ab9e1c379a19f548e851ae3838d7e4 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Tue, 13 Jul 2021 11:18:33 +0200
Subject: [PATCH] WIP: basic c interface

---
 CMakeLists.txt  |  2 +-
 conanfile.py    |  2 +-
 src/ccaosdb.cpp | 15 +++++++++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2cfac1c..f19cc29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@
 
 cmake_minimum_required(VERSION 3.14)
 
-set(libcaosdb_VERSION 0.0.4)
+set(libcaosdb_VERSION 0.0.5)
 
 project(libcaosdb
     VERSION ${libcaosdb_VERSION}
diff --git a/conanfile.py b/conanfile.py
index 88d6c98..c8bba23 100644
--- a/conanfile.py
+++ b/conanfile.py
@@ -3,7 +3,7 @@ from conans import ConanFile, CMake, tools
 
 class CaosdbConan(ConanFile):
     name = "caosdb"
-    version = "0.0.4"
+    version = "0.0.5"
     license = "AGPL-3.0-or-later"
     author = "Timm C. Fitschen <t.fitschen@indiscale.com>"
     url = "https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib.git"
diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp
index 076b23e..4465c78 100644
--- a/src/ccaosdb.cpp
+++ b/src/ccaosdb.cpp
@@ -1,3 +1,5 @@
+#include <iostream>
+#include <stdio.h>
 #include "caosdb/utility.h"
 #include "caosdb/constants.h"
 #include "caosdb/connection.h"
@@ -121,8 +123,17 @@ int caosdb_connection_get_version_info(
   out->minor = (int)version_info->GetMinor();
   out->patch = (int)version_info->GetPatch();
 
-  out->pre_release = version_info->GetPreRelease().c_str();
-  out->build = version_info->GetBuild().c_str();
+  // copy pre_release, needs local variable because out->pre_release is const
+  char *pre_release =
+    (char *)malloc(sizeof(char) * (version_info->GetPreRelease().length() + 1));
+  strcpy(pre_release, version_info->GetPreRelease().c_str());
+  out->pre_release = pre_release;
+
+  // copy build, needs local variable because out->build is const
+  char *build =
+    (char *)malloc(sizeof(char) * (version_info->GetBuild().length() + 1));
+  strcpy(build, version_info->GetBuild().c_str());
+  out->build = build;
 
   return 0;
 }
-- 
GitLab