Browse Source

just a vector should be enough

AllGroupDevicesShowHandshake
Volker Birk 6 years ago
parent
commit
1cff663240
2 changed files with 3 additions and 78 deletions
  1. +0
    -66
      src/message.cc
  2. +3
    -12
      src/message.hh

+ 0
- 66
src/message.cc View File

@ -5,72 +5,6 @@ namespace pEp {
namespace PythonAdapter {
using namespace std;
Message::Blob::Blob(char *value, size_t size, string mime_type,
string filename) : _value(value), _size(size),
_mime_type(mime_type), _filename(filename)
{
}
Message::Blob::Blob(const Blob& second, bool copy)
{
_size = second._size;
if (copy) {
_value = (char *) malloc(_size);
if (!_value)
throw bad_alloc();
memcpy(_value, second._value, _size);
}
else {
_value = second._value;
}
_mime_type = second._mime_type;
_filename = second._filename;
}
Message::Blob::Blob(bloblist_t *bl)
{
_value = NULL;
attach(bl);
}
Message::Blob::~Blob()
{
free(_value);
}
void Message::Blob::attach(bloblist_t *blob)
{
free(_value);
_size = blob->size;
_value = blob->value;
blob->size = 0;
blob->value = NULL;
if (blob->mime_type) {
_mime_type = blob->mime_type;
free(blob->mime_type);
blob->mime_type = NULL;
}
if (blob->filename) {
_filename = blob->filename;
free(blob->filename);
blob->filename = NULL;
}
}
bloblist_t * Message::Blob::detach()
{
bloblist_t *bl = new_bloblist(_value, _size, _mime_type.c_str(),
_filename.c_str());
if (!bl)
throw bad_alloc();
_size = 0;
_value = NULL;
_mime_type = "";
_filename = "";
return bl;
}
Message::Message(PEP_msg_direction dir)
: _msg(new_message(dir))
{


+ 3
- 12
src/message.hh View File

@ -3,6 +3,7 @@
#include <pEp/message.h>
#include <string>
#include <list>
#include <vector>
#include "str_attr.hh"
namespace pEp {
@ -10,20 +11,10 @@ namespace pEp {
using namespace utility;
class Message {
class Blob {
char *_value;
size_t _size;
struct Blob {
vector<char> _value;
string _mime_type;
string _filename;
public:
Blob(char *value = NULL, size_t size = 0, string mime_type = "",
string filename = "");
Blob(bloblist_t *bl);
Blob(const Blob& second, bool copy = false);
~Blob();
void attach(bloblist_t *blob);
bloblist_t *detach();
};
message *_msg;


Loading…
Cancel
Save