- 1
- 2
- 3
- 4
- 5
- 6
- 7
void operator()()
{
for (std::list<SmartPointer<FunctorTriggerParent > >::iterator it = _listFunctorOnTrigger.begin(); it != _listFunctorOnTrigger.end(); ++it)
{
(*it)->operator ()();
}
};
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+10
void operator()()
{
for (std::list<SmartPointer<FunctorTriggerParent > >::iterator it = _listFunctorOnTrigger.begin(); it != _listFunctorOnTrigger.end(); ++it)
{
(*it)->operator ()();
}
};
+80
new
+18
std::string MetaInfo::SetField() {
return m_value;
}
/* ... */
std::string value = meta.SetValue();
Йода-стайл. Переменную эту, хочешь установить ты.
+13
int offset;
/* где-то ниже */
if (offset <= NULL)
{
}
Антиматерия существует...
+10
int ScriptArrow;
...
// проверим а есть ли в натуре скрипт по этому указателю
try
{
RunScript = (Script*)ScriptArrow;
RunScript->Script.ArrVar.count();
}
catch (...)
{
RunScript = NULL;
}
Проверка, в натуре. Авторский комментарий сохранен :)
+22
printf("Куда все подевались? Ни одного коммента за два дня...\n");
+11
// This is an example of an exported function.
SCCONNECT_API int fnSCConnect(void)
{
return 42;
}
Не говно, но не мог промолчать!
Вот такой шаблон функции генерирует MSVC при создании DLL.
MSVC даёт ответ на самый главный вопрос жизни, вселенной и всего такого!
+2
class pool_exeption: public std::exception
{
virtual const char* what() const throw()
{
return "Pool out of bounds";
}
}pool_out_of_bounds;
class pool_exeption2: public std::exception
{
virtual const char* what() const throw()
{
return "Pool block is too small";
}
}pool_small_block;
А потом эти исключения кидаются по значению: throw pool_out_of_bounds;
virtual const char* WAT()
+8
QRegExp re("<cite>(.*)</cite>");
re.setMinimal(true);
qDebug() << re.indexIn("<cite>http://test.com/</cite>");
Ошибка, на фикс которой мы с другом убили почти час.
+4
int DataBase::garbageCollector(string filename){
fstream from(filename.c_str());
fstream from0((filename+".index").c_str());
Index x;
Data d;
char *a/*,*b*/;
int oldpos = 0 ;
bool done = false;
from.seekg(0,ios::end);
int dbend = static_cast<int>(from.tellp());
from0.seekg(0,ios::end);
int indexend = static_cast<int>(from0.tellp());
if(dbend == BlockSize || indexend == IndexSize){
from.close();
from0.close();
return 0;
}
from.seekg(0,ios::beg);
from0.seekg(0,ios::beg);
while(true){
from0 >> x;
if(from0.eof())break;
if(!x.Num()){
int count = dbend - x.Pointer() - BlockSize;
int count0 = indexend - (static_cast<int>(from0.tellp())+1);
from.seekg(x.Pointer()+BlockSize);
a = new char[count];
from.read(a,count);
from.seekp(x.Pointer());
from.write(a,count);
delete a;
a = new char[count0];
from0.seekp(1,ios::cur);
int test = from0.tellp();
from0.read(a,count0);
from0.clear();
from0.seekp(indexend - count0 - IndexSize,ios::beg);
test = from0.tellp();
from0.write(a,count0);
test = from0.tellp();
delete a;
ofstream to("tmp.base",ios::trunc),to0("tmp.index",ios::trunc);
a = new char[dbend - BlockSize];
from.seekg(0,ios::beg);
from.read(a,dbend - BlockSize);
to.write(a,dbend - BlockSize);
delete a;
a = new char[indexend - IndexSize];
from0.seekg(0,ios::beg);
test = from0.tellp();
from0.read(a,indexend - IndexSize);
to0.write(a,indexend - IndexSize);
delete a;
from.close();
from0.close();
if(remove(filename.c_str()) || rename("tmp.base",filename.c_str())) return -1;
if(remove((filename+".index").c_str()) || rename("tmp.index",(filename+".index").c_str())) return -1;
oldpos = indexend - count0 - IndexSize;
done = true;
break;
}
}
if(done){
from0.open((filename+".index").c_str());
while(true){
from0 >> x;
if(from0.eof())break;
if(x.Pointer() > static_cast<unsigned>((oldpos/23)*BlockSize) ){
x.Pointer(x.Pointer()-BlockSize);
from0.seekp(-(IndexSize-1),ios::cur);
from0 << x;
int test = from0.tellp();
}
else{
from0.seekp(-(IndexSize-1),ios::cur);
from0 << x;
int test = from0.tellp();
from0.clear();
}
}
}
return 0;
}
Собираем пустые блоки