Ok, allora per chiudere il thread ti chiedo se secondo te il codice che segue può portare a delle memory leaks di qualche tipo:
codice:
#include <windows.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <boost/circular_buffer.hpp>
using namespace std;
using namespace boost;
void getDateTime(char * szTime);
const int numbuff = 3;
const int buflen = 30;
struct buffer
{
char data[1024];
int bytesRecorded;
buffer(const char * data_, const int bytesRecorded_) :
bytesRecorded(bytesRecorded_)
{
copy(data_, data_ + (bytesRecorded_ * sizeof(char)), data);
}
};
int main()
{
circular_buffer<buffer> cb(numbuff);
// Insert elements
cout << "Push elements:" << endl;
for(int i = 0; i < 10; i++)
{
char szTime[30]; getDateTime(szTime);
cb.push_back( buffer(szTime, 30) );
cout << szTime << endl;
Sleep(1000);
}
// Show elements:
cout << "Show elements:" << endl;
for(int i = 0; i<(int)cb.size(); i++)
{
cout << &cb[i].data[0] << endl;
}
system("pause");
return EXIT_SUCCESS;
}
void getDateTime(char * szTime)
{
time_t rawtime = time(NULL);
struct tm timeinfo;
gmtime_s(&timeinfo, &rawtime);
strftime(szTime, 30, "%a, %d %b %Y %X GMT", &timeinfo);
}
inoltre il codice mi sembra molto vicino al C++ anche se non usa string...(ma ti ho già spiegato che non posso!)
grazie