src/core/alloc_func.cpp
author richk
Wed, 16 Apr 2008 22:16:04 +0000
branchNewGRF_ports
changeset 10210 a2131f7a315d
parent 6878 7d1ff2f621c7
child 10246 707c09e2e42b
permissions -rw-r--r--
(svn r12742) [NewGRF_ports] -Sync: with trunk r12673:12705.
6878
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     1
/* $Id$ */
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     2
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     3
/** @file alloc_func.cpp functions to 'handle' memory allocation errors */
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     4
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     5
#include "../stdafx.h"
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     6
#include "alloc_func.hpp"
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     7
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     8
/**
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
     9
 * Function to exit with an error message after malloc() or calloc() have failed
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    10
 * @param size number of bytes we tried to allocate
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    11
 */
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    12
void MallocError(size_t size)
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    13
{
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    14
	error("Out of memory. Cannot allocate %i bytes", size);
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    15
}
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    16
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    17
/**
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    18
 * Function to exit with an error message after realloc() have failed
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    19
 * @param size number of bytes we tried to allocate
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    20
 */
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    21
void ReallocError(size_t size)
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    22
{
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    23
	error("Out of memory. Cannot reallocate %i bytes", size);
7d1ff2f621c7 (svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
diff changeset
    24
}