Skip to content
Snippets Groups Projects
Commit fd98bfad authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Replace std::string with C-style string

parent 59288f02
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp> #include <boost/shared_array.hpp>
#include <cstring>
#include "flandmark_detector.h" #include "flandmark_detector.h"
/****************************************** /******************************************
...@@ -50,7 +52,7 @@ static auto s_class = xbob::extension::ClassDoc( ...@@ -50,7 +52,7 @@ static auto s_class = xbob::extension::ClassDoc(
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
FLANDMARK_Model* flandmark; FLANDMARK_Model* flandmark;
std::string filename; char* filename;
} PyBobIpFlandmarkObject; } PyBobIpFlandmarkObject;
static int PyBobIpFlandmark_init static int PyBobIpFlandmark_init
...@@ -98,7 +100,7 @@ static int PyBobIpFlandmark_init ...@@ -98,7 +100,7 @@ static int PyBobIpFlandmark_init
} }
//flandmark is now initialized, set filename //flandmark is now initialized, set filename
self->filename = c_filename; self->filename = strndup(c_filename, 256);
//all good, flandmark is ready //all good, flandmark is ready
return 0; return 0;
...@@ -108,6 +110,8 @@ static int PyBobIpFlandmark_init ...@@ -108,6 +110,8 @@ static int PyBobIpFlandmark_init
static void PyBobIpFlandmark_delete (PyBobIpFlandmarkObject* self) { static void PyBobIpFlandmark_delete (PyBobIpFlandmarkObject* self) {
flandmark_free(self->flandmark); flandmark_free(self->flandmark);
self->flandmark = 0; self->flandmark = 0;
free(self->filename);
self->filename = 0;
Py_TYPE(self)->tp_free((PyObject*)self); Py_TYPE(self)->tp_free((PyObject*)self);
} }
...@@ -269,7 +273,7 @@ PyObject* PyBobIpFlandmark_Repr(PyBobIpFlandmarkObject* self) { ...@@ -269,7 +273,7 @@ PyObject* PyBobIpFlandmark_Repr(PyBobIpFlandmarkObject* self) {
*/ */
PyObject* retval = PyUnicode_FromFormat("<%s(model='%s')>", 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 PYTHON_VERSION_HEX < 0x03000000
if (!retval) return 0; if (!retval) return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment