1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-12-04 16:24:16 +01:00
HLMetaModOfficial/sourcehook/sourcehook_impl_cproto.h
Pavol Marko bf7ebed87d Fixed a problem where sourcehook ignored references in prototypes (could result in stack corruptions in some conditions)
--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40503
2007-10-12 19:17:52 +00:00

88 lines
1.6 KiB
C++

/* ======== SourceHook ========
* Copyright (C) 2004-2007 Metamod:Source Development Team
* No warranties of any kind
*
* License: zlib/libpng
*
* Author(s): Pavol "PM OnoTo" Marko
* ============================
*/
#ifndef __SOURCEHOOK_IMPL_CPROTO_H__
#define __SOURCEHOOK_IMPL_CPROTO_H__
namespace SourceHook
{
namespace Impl
{
class CProto
{
ProtoInfo *m_Proto;
static bool Equal(const ProtoInfo *p1, const ProtoInfo *p2);
static ProtoInfo *DupProto(const ProtoInfo *src);
static void FreeProto(ProtoInfo *prot);
public:
CProto() : m_Proto(NULL)
{
}
CProto(const ProtoInfo *pProto) : m_Proto(DupProto(pProto))
{
}
CProto(const CProto &other) : m_Proto(DupProto(other.m_Proto))
{
}
~CProto()
{
FreeProto(m_Proto);
m_Proto = NULL;
}
void operator = (const ProtoInfo *pProto)
{
if (m_Proto)
FreeProto(m_Proto);
m_Proto = DupProto(pProto);
}
void operator = (const CProto &other)
{
if (m_Proto)
FreeProto(m_Proto);
m_Proto = DupProto(other.m_Proto);
}
bool operator == (const ProtoInfo *pProto) const
{
return Equal(pProto, m_Proto);
}
bool operator == (const CProto &other) const
{
return Equal(other.m_Proto, m_Proto);
}
const ProtoInfo *GetProto() const
{
return m_Proto;
}
static size_t GetRealSize(const PassInfo &info)
{
if (info.flags & PassInfo::PassFlag_ByRef)
{
return sizeof(void*);
}
return info.size;
}
};
}
}
#endif