src/core/alloc_func.cpp
author richk
Sun, 20 Apr 2008 15:27:28 +0000
branchNewGRF_ports
changeset 10274 b3c58f3df92b
parent 6878 7d1ff2f621c7
child 10429 1b99254f9607
permissions -rw-r--r--
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
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
 */
10274
b3c58f3df92b (svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents: 6878
diff changeset
    12
void NORETURN MallocError(size_t size)
6878
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
 */
10274
b3c58f3df92b (svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents: 6878
diff changeset
    21
void NORETURN ReallocError(size_t size)
6878
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
}