From fd98bfad9097c2aa0850f8ce677f0d0579adc77e Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.anjos@idiap.ch>
Date: Thu, 24 Apr 2014 14:57:14 +0200
Subject: [PATCH] Replace std::string with C-style string

---
 xbob/ip/flandmark/flandmark.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/xbob/ip/flandmark/flandmark.cpp b/xbob/ip/flandmark/flandmark.cpp
index 5dead11..689da94 100644
--- a/xbob/ip/flandmark/flandmark.cpp
+++ b/xbob/ip/flandmark/flandmark.cpp
@@ -15,6 +15,8 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_array.hpp>
 
+#include <cstring>
+
 #include "flandmark_detector.h"
 
 /******************************************
@@ -50,7 +52,7 @@ static auto s_class = xbob::extension::ClassDoc(
 typedef struct {
   PyObject_HEAD
   FLANDMARK_Model* flandmark;
-  std::string filename;
+  char* filename;
 } PyBobIpFlandmarkObject;
 
 static int PyBobIpFlandmark_init
@@ -98,7 +100,7 @@ static int PyBobIpFlandmark_init
   }
 
   //flandmark is now initialized, set filename
-  self->filename = c_filename;
+  self->filename = strndup(c_filename, 256);
 
   //all good, flandmark is ready
   return 0;
@@ -108,6 +110,8 @@ static int PyBobIpFlandmark_init
 static void PyBobIpFlandmark_delete (PyBobIpFlandmarkObject* self) {
   flandmark_free(self->flandmark);
   self->flandmark = 0;
+  free(self->filename);
+  self->filename = 0;
   Py_TYPE(self)->tp_free((PyObject*)self);
 }
 
@@ -269,7 +273,7 @@ PyObject* PyBobIpFlandmark_Repr(PyBobIpFlandmarkObject* self) {
    */
 
   PyObject* retval = PyUnicode_FromFormat("<%s(model='%s')>",
-      Py_TYPE(self)->tp_name, self->filename.c_str());
+      Py_TYPE(self)->tp_name, self->filename);
 
 #if PYTHON_VERSION_HEX < 0x03000000
   if (!retval) return 0;
-- 
GitLab