2010-03-04 05:02:56 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: sw=4 ts=4 et :
|
|
|
|
*/
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-04 05:02:56 +00:00
|
|
|
|
2010-11-09 10:13:03 +00:00
|
|
|
#if defined(XP_WIN) || defined(XP_OS2)
|
2010-04-08 18:05:02 +00:00
|
|
|
# define MOZALLOC_EXPORT __declspec(dllexport)
|
|
|
|
#endif
|
|
|
|
|
2010-04-20 20:12:02 +00:00
|
|
|
#include "mozilla/mozalloc_abort.h"
|
2010-03-04 05:02:56 +00:00
|
|
|
#include "mozilla/mozalloc_oom.h"
|
|
|
|
|
2012-01-24 16:08:51 +00:00
|
|
|
static mozalloc_oom_abort_handler gAbortHandler;
|
|
|
|
|
2010-03-04 05:02:56 +00:00
|
|
|
void
|
2012-01-24 16:08:51 +00:00
|
|
|
mozalloc_handle_oom(size_t size)
|
2010-03-04 05:02:56 +00:00
|
|
|
{
|
|
|
|
// NB: this is handle_oom() stage 1, which simply aborts on OOM.
|
|
|
|
// we might proceed to a stage 2 in which an attempt is made to
|
|
|
|
// reclaim memory
|
2012-01-24 16:08:51 +00:00
|
|
|
|
|
|
|
if (gAbortHandler)
|
|
|
|
gAbortHandler(size);
|
|
|
|
|
2010-04-20 20:12:02 +00:00
|
|
|
mozalloc_abort("out of memory");
|
2010-03-04 05:02:56 +00:00
|
|
|
}
|
2012-01-24 16:08:51 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler)
|
|
|
|
{
|
|
|
|
gAbortHandler = handler;
|
|
|
|
}
|