summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/binaryheap.hpp56
-rw-r--r--src/misc/blob.hpp28
-rw-r--r--src/misc/countedptr.hpp2
-rw-r--r--src/misc/crc32.hpp4
-rw-r--r--src/misc/dbg_helpers.cpp6
-rw-r--r--src/misc/fixedsizearray.hpp14
-rw-r--r--src/misc/hashtable.hpp16
-rw-r--r--src/misc/strapi.hpp16
8 files changed, 71 insertions, 71 deletions
diff --git a/src/misc/binaryheap.hpp b/src/misc/binaryheap.hpp
index 2206ccd03..7fce75356 100644
--- a/src/misc/binaryheap.hpp
+++ b/src/misc/binaryheap.hpp
@@ -94,9 +94,9 @@ FORCEINLINE bool CBinaryHeapT<Titem_>::Push(Titem_& new_item)
{
if (IsFull()) return false;
- // make place for new item
+ /* make place for new item */
int gap = ++m_size;
- // Heapify up
+ /* Heapify up */
for (int parent = gap / 2; (parent > 0) && (new_item < *m_items[parent]); gap = parent, parent /= 2)
m_items[gap] = m_items[parent];
m_items[gap] = &new_item;
@@ -109,35 +109,35 @@ FORCEINLINE void CBinaryHeapT<Titem_>::RemoveHead()
{
assert(!IsEmpty());
- // at index 1 we have a gap now
+ /* at index 1 we have a gap now */
int gap = 1;
- // Heapify down:
- // last item becomes a candidate for the head. Call it new_item.
+ /* Heapify down:
+ * last item becomes a candidate for the head. Call it new_item. */
Titem_& new_item = *m_items[m_size--];
- // now we must maintain relation between parent and its children:
- // parent <= any child
- // from head down to the tail
+ /* now we must maintain relation between parent and its children:
+ * parent <= any child
+ * from head down to the tail */
int child = 2; // first child is at [parent * 2]
- // while children are valid
+ /* while children are valid */
while (child <= m_size) {
- // choose the smaller child
+ /* choose the smaller child */
if (child < m_size && *m_items[child + 1] < *m_items[child])
child++;
- // is it smaller than our parent?
+ /* is it smaller than our parent? */
if (!(*m_items[child] < new_item)) {
- // the smaller child is still bigger or same as parent => we are done
+ /* the smaller child is still bigger or same as parent => we are done */
break;
}
- // if smaller child is smaller than parent, it will become new parent
+ /* if smaller child is smaller than parent, it will become new parent */
m_items[gap] = m_items[child];
gap = child;
- // where do we have our new children?
+ /* where do we have our new children? */
child = gap * 2;
}
- // move last item to the proper place
+ /* move last item to the proper place */
if (m_size > 0) m_items[gap] = &new_item;
CheckConsistency();
}
@@ -145,45 +145,45 @@ FORCEINLINE void CBinaryHeapT<Titem_>::RemoveHead()
template <class Titem_>
inline void CBinaryHeapT<Titem_>::RemoveByIdx(int idx)
{
- // at position idx we have a gap now
+ /* at position idx we have a gap now */
int gap = idx;
Titem_& last = *m_items[m_size];
if (idx < m_size) {
assert(idx >= 1);
m_size--;
- // and the candidate item for fixing this gap is our last item 'last'
- // Move gap / last item up:
+ /* and the candidate item for fixing this gap is our last item 'last'
+ * Move gap / last item up: */
while (gap > 1)
{
- // compare [gap] with its parent
+ /* compare [gap] with its parent */
int parent = gap / 2;
if (last < *m_items[parent]) {
m_items[gap] = m_items[parent];
gap = parent;
} else {
- // we don't need to continue upstairs
+ /* we don't need to continue upstairs */
break;
}
}
- // Heapify (move gap) down:
+ /* Heapify (move gap) down: */
while (true) {
- // where we do have our children?
+ /* where we do have our children? */
int child = gap * 2; // first child is at [parent * 2]
if (child > m_size) break;
- // choose the smaller child
+ /* choose the smaller child */
if (child < m_size && *m_items[child + 1] < *m_items[child])
child++;
- // is it smaller than our parent?
+ /* is it smaller than our parent? */
if (!(*m_items[child] < last)) {
- // the smaller child is still bigger or same as parent => we are done
+ /* the smaller child is still bigger or same as parent => we are done */
break;
}
- // if smaller child is smaller than parent, it will become new parent
+ /* if smaller child is smaller than parent, it will become new parent */
m_items[gap] = m_items[child];
gap = child;
}
- // move parent to the proper place
+ /* move parent to the proper place */
if (m_size > 0) m_items[gap] = &last;
}
else {
@@ -208,7 +208,7 @@ inline int CBinaryHeapT<Titem_>::FindLinear(const Titem_& item) const
template <class Titem_>
FORCEINLINE void CBinaryHeapT<Titem_>::CheckConsistency()
{
- // enable it if you suspect binary heap doesn't work well
+ /* enable it if you suspect binary heap doesn't work well */
#if 0
for (int child = 2; child <= m_size; child++) {
int parent = child / 2;
diff --git a/src/misc/blob.hpp b/src/misc/blob.hpp
index 6238cba3e..56e10a7cf 100644
--- a/src/misc/blob.hpp
+++ b/src/misc/blob.hpp
@@ -250,19 +250,19 @@ public:
{
bsize_t old_max_size = MaxRawSize();
if (old_max_size >= new_size) return;
- // calculate minimum block size we need to allocate
+ /* calculate minimum block size we need to allocate */
bsize_t min_alloc_size = sizeof(CHdr) + new_size + Ttail_reserve;
- // ask allocation policy for some reasonable block size
+ /* ask allocation policy for some reasonable block size */
bsize_t alloc_size = AllocPolicy(min_alloc_size);
- // allocate new block
+ /* allocate new block */
CHdr *pNewHdr = RawAlloc(alloc_size);
- // setup header
+ /* setup header */
pNewHdr->m_size = RawSize();
pNewHdr->m_max_size = alloc_size - (sizeof(CHdr) + Ttail_reserve);
- // copy existing data
+ /* copy existing data */
if (RawSize() > 0)
memcpy(pNewHdr + 1, ptr_u.m_pData, pNewHdr->m_size);
- // replace our block with new one
+ /* replace our block with new one */
CHdr *pOldHdr = &Hdr();
Init(pNewHdr);
if (old_max_size > 0)
@@ -320,7 +320,7 @@ public:
* 4. Dynamically constructs only used items (as opposite of static array which constructs all items) */
template <class Titem_, class Tbase_ = CBlobBaseSimple>
class CBlobT : public Tbase_ {
- // make template arguments public:
+ /* make template arguments public: */
public:
typedef Titem_ Titem;
typedef Tbase_ Tbase;
@@ -418,7 +418,7 @@ public:
assert((Tbase::RawSize() % Titem_size) == 0);
bsize_t old_size = Size();
if (old_size > 0) {
- // destroy removed items;
+ /* destroy removed items; */
Titem *pI_last_to_destroy = Data(0);
for (Titem *pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem_();
}
@@ -445,10 +445,10 @@ public:
bsize_t old_size = Size();
assert(num_items <= old_size);
bsize_t new_size = (num_items <= old_size) ? (old_size - num_items) : 0;
- // destroy removed items;
+ /* destroy removed items; */
Titem *pI_last_to_destroy = Data(new_size);
for (Titem *pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem();
- // remove them
+ /* remove them */
Tbase::ReduceRawSize(num_items * Titem_size);
}
@@ -482,7 +482,7 @@ public:
FORCEINLINE void RemoveBySwap(bsize_t idx)
{
CheckIdx(idx);
- // destroy removed item
+ /* destroy removed item */
Titem *pRemoved = Data(idx);
RemoveBySwap(pRemoved);
}
@@ -492,14 +492,14 @@ public:
{
Titem *pLast = Data(Size() - 1);
assert(pItem >= Data() && pItem <= pLast);
- // move last item to its new place
+ /* move last item to its new place */
if (pItem != pLast) {
pItem->~Titem_();
new (pItem) Titem_(*pLast);
}
- // destroy the last item
+ /* destroy the last item */
pLast->~Titem_();
- // and reduce the raw blob size
+ /* and reduce the raw blob size */
Tbase::ReduceRawSize(Titem_size);
}
diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp
index 59e1273a6..f72d87ba5 100644
--- a/src/misc/countedptr.hpp
+++ b/src/misc/countedptr.hpp
@@ -86,7 +86,7 @@ public:
template <class Tcls_>
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT)
{
- // if they are the same, we do nothing
+ /* if they are the same, we do nothing */
if (pT != m_pT) {
if (pT) pT->AddRef(); // AddRef new pointer if any
Tcls *pTold = m_pT; // save original ptr
diff --git a/src/misc/crc32.hpp b/src/misc/crc32.hpp
index 2c0ca3abd..4843023df 100644
--- a/src/misc/crc32.hpp
+++ b/src/misc/crc32.hpp
@@ -5,7 +5,7 @@
#ifndef CRC32_HPP
#define CRC32_HPP
-#if 0 // reenable when needed
+#if 0 /* reenable when needed */
struct CCrc32
{
static uint32 Calc(const void *pBuffer, int nCount)
@@ -62,6 +62,6 @@ struct CCrc32
return Table;
}
};
-#endif // 0
+#endif /* 0 */
#endif /* CRC32_HPP */
diff --git a/src/misc/dbg_helpers.cpp b/src/misc/dbg_helpers.cpp
index 305f7361e..1eebfdf45 100644
--- a/src/misc/dbg_helpers.cpp
+++ b/src/misc/dbg_helpers.cpp
@@ -65,8 +65,8 @@ CStrA TileStr(TileIndex tile)
return out.Transfer();
}
-/** Keep track of the last assigned type_id. Used for anti-recursion. */
-/*static*/ size_t& DumpTarget::LastTypeId()
+/** Keep track of the last assigned type_id. Used for anti-recursion.
+ *static*/ size_t& DumpTarget::LastTypeId()
{
static size_t last_type_id = 0;
return last_type_id;
@@ -77,7 +77,7 @@ CStrA DumpTarget::GetCurrentStructName()
{
CStrA out;
if (!m_cur_struct.empty()) {
- // we are inside some named struct, return its name
+ /* we are inside some named struct, return its name */
out = m_cur_struct.top();
}
return out.Transfer();
diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp
index cd3d8c904..a979fae1e 100644
--- a/src/misc/fixedsizearray.hpp
+++ b/src/misc/fixedsizearray.hpp
@@ -23,7 +23,7 @@ struct CFixedSizeArrayT {
int m_ref_cnt; ///< block reference counter (used by copy constructor and by destructor)
};
- // make types and constants visible from outside
+ /* make types and constants visible from outside */
typedef Titem_ Titem; // type of array item
static const int Tcapacity = Tcapacity_; // the array capacity (maximum size)
@@ -33,7 +33,7 @@ struct CFixedSizeArrayT {
/** Default constructor. Preallocate space for items and header, then initialize header. */
CFixedSizeArrayT()
{
- // allocate block for header + items (don't construct items)
+ /* allocate block for header + items (don't construct items) */
m_items = (Titem*)((MallocT<int8>(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize);
SizeRef() = 0; // initial number of items
RefCnt() = 1; // initial reference counter
@@ -42,7 +42,7 @@ struct CFixedSizeArrayT {
/** Copy constructor. Preallocate space for items and header, then initialize header. */
CFixedSizeArrayT(const CFixedSizeArrayT<Titem_, Tcapacity_>& src)
{
- // share block (header + items) with the source array
+ /* share block (header + items) with the source array */
m_items = src.m_items;
RefCnt()++; // now we share block with the source
}
@@ -50,11 +50,11 @@ struct CFixedSizeArrayT {
/** destroy remaining items and free the memory block */
~CFixedSizeArrayT()
{
- // release one reference to the shared block
+ /* release one reference to the shared block */
if ((--RefCnt()) > 0) return; // and return if there is still some owner
Clear();
- // free the memory block occupied by items
+ /* free the memory block occupied by items */
free(((int8*)m_items) - ThdrSize);
m_items = NULL;
}
@@ -62,11 +62,11 @@ struct CFixedSizeArrayT {
/** Clear (destroy) all items */
FORCEINLINE void Clear()
{
- // walk through all allocated items backward and destroy them
+ /* walk through all allocated items backward and destroy them */
for (Titem *pItem = &m_items[Size() - 1]; pItem >= m_items; pItem--) {
pItem->~Titem_();
}
- // number of items become zero
+ /* number of items become zero */
SizeRef() = 0;
}
diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp
index 2f1c18530..05430f446 100644
--- a/src/misc/hashtable.hpp
+++ b/src/misc/hashtable.hpp
@@ -22,7 +22,7 @@ struct CHashTableSlotT
{
for (const Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
if (pItem->GetKey() == key) {
- // we have found the item, return it
+ /* we have found the item, return it */
return pItem;
}
}
@@ -34,7 +34,7 @@ struct CHashTableSlotT
{
for (Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
if (pItem->GetKey() == key) {
- // we have found the item, return it
+ /* we have found the item, return it */
return pItem;
}
}
@@ -74,22 +74,22 @@ struct CHashTableSlotT
/** hash table slot helper - remove and return item from a slot */
FORCEINLINE Titem_ *Detach(const Key& key)
{
- // do we have any items?
+ /* do we have any items? */
if (m_pFirst == NULL) {
return NULL;
}
- // is it our first item?
+ /* is it our first item? */
if (m_pFirst->GetKey() == key) {
Titem_& ret_item = *m_pFirst;
m_pFirst = m_pFirst->GetHashNext();
ret_item.SetHashNext(NULL);
return &ret_item;
}
- // find it in the following items
+ /* find it in the following items */
Titem_ *pPrev = m_pFirst;
for (Titem_ *pItem = m_pFirst->GetHashNext(); pItem != NULL; pPrev = pItem, pItem = pItem->GetHashNext()) {
if (pItem->GetKey() == key) {
- // we have found the item, unlink and return it
+ /* we have found the item, unlink and return it */
pPrev->SetHashNext(pItem->GetHashNext());
pItem->SetHashNext(NULL);
return pItem;
@@ -137,10 +137,10 @@ protected:
int m_num_items; // item counter
public:
- // default constructor
+ /* default constructor */
FORCEINLINE CHashTableT()
{
- // construct all slots
+ /* construct all slots */
m_slots = new Slot[Tcapacity];
m_num_items = 0;
}
diff --git a/src/misc/strapi.hpp b/src/misc/strapi.hpp
index 7fe48d098..468fac15b 100644
--- a/src/misc/strapi.hpp
+++ b/src/misc/strapi.hpp
@@ -30,13 +30,13 @@ public:
};
/** ::strlen wrapper specialization for char */
-template <> /*static*/ inline size_t CStrApiBaseT<char>::StrLen(const char *s)
+template <> /* static */ inline size_t CStrApiBaseT<char>::StrLen(const char *s)
{
return ::strlen(s);
}
/** ::vsprintf wrapper specialization for char */
-template <> /*static*/ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t count, const char *fmt, va_list args)
+template <> /* static */ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t count, const char *fmt, va_list args)
{
#if defined(_MSC_VER) && !defined(WINCE)
return ::vsnprintf_s(buf, count, count - 1, fmt, args);
@@ -47,13 +47,13 @@ template <> /*static*/ inline int CStrApiBaseT<char>::SPrintFL(char *buf, size_t
#if defined(HAS_WCHAR)
/** ::strlen wrapper specialization for wchar_t */
-template <> /*static*/ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t *s)
+template <> /* static */ inline size_t CStrApiBaseT<wchar_t>::StrLen(const wchar_t *s)
{
return ::wcslen(s);
}
/** ::vsprintf wrapper specialization for wchar_t */
-template <> /*static*/ inline int CStrApiBaseT<wchar_t>::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args)
+template <> /* static */ inline int CStrApiBaseT<wchar_t>::SPrintFL(wchar_t *buf, size_t count, const wchar_t *fmt, va_list args)
{
#if defined(_MSC_VER) && !defined(WINCE)
return ::_vsnwprintf_s(buf, count, count - 1, fmt, args);
@@ -76,23 +76,23 @@ public:
static int StrCmp(const Tchar *s1, const Tchar *s2);
};
-template <> /*static*/ inline int CStrApiT<char, false>::StrCmp(const char *s1, const char *s2)
+template <> /* static */ inline int CStrApiT<char, false>::StrCmp(const char *s1, const char *s2)
{
return ::strcmp(s1, s2);
}
-template <> /*static*/ inline int CStrApiT<char, true>::StrCmp(const char *s1, const char *s2)
+template <> /* static */ inline int CStrApiT<char, true>::StrCmp(const char *s1, const char *s2)
{
return ::_stricmp(s1, s2);
}
#if defined(HAS_WCHAR)
-template <> /*static*/ inline int CStrApiT<wchar_t, false>::StrCmp(const wchar_t *s1, const wchar_t *s2)
+template <> /* static */ inline int CStrApiT<wchar_t, false>::StrCmp(const wchar_t *s1, const wchar_t *s2)
{
return ::wcscmp(s1, s2);
}
-template <> /*static*/ inline int CStrApiT<wchar_t, true>::StrCmp(const wchar_t *s1, const wchar_t *s2)
+template <> /* static */ inline int CStrApiT<wchar_t, true>::StrCmp(const wchar_t *s1, const wchar_t *s2)
{
return ::_wcsicmp(s1, s2);
}