Blame glib/pcre/pcre_globals.c

Packit ae235b
/*************************************************
Packit ae235b
*      Perl-Compatible Regular Expressions       *
Packit ae235b
*************************************************/
Packit ae235b
Packit ae235b
/* PCRE is a library of functions to support regular expressions whose syntax
Packit ae235b
and semantics are as close as possible to those of the Perl 5 language.
Packit ae235b
Packit ae235b
                       Written by Philip Hazel
Packit ae235b
           Copyright (c) 1997-2012 University of Cambridge
Packit ae235b
Packit ae235b
-----------------------------------------------------------------------------
Packit ae235b
Redistribution and use in source and binary forms, with or without
Packit ae235b
modification, are permitted provided that the following conditions are met:
Packit ae235b
Packit ae235b
    * Redistributions of source code must retain the above copyright notice,
Packit ae235b
      this list of conditions and the following disclaimer.
Packit ae235b
Packit ae235b
    * Redistributions in binary form must reproduce the above copyright
Packit ae235b
      notice, this list of conditions and the following disclaimer in the
Packit ae235b
      documentation and/or other materials provided with the distribution.
Packit ae235b
Packit ae235b
    * Neither the name of the University of Cambridge nor the names of its
Packit ae235b
      contributors may be used to endorse or promote products derived from
Packit ae235b
      this software without specific prior written permission.
Packit ae235b
Packit ae235b
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit ae235b
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit ae235b
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit ae235b
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
Packit ae235b
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Packit ae235b
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Packit ae235b
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit ae235b
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Packit ae235b
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Packit ae235b
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Packit ae235b
POSSIBILITY OF SUCH DAMAGE.
Packit ae235b
-----------------------------------------------------------------------------
Packit ae235b
*/
Packit ae235b
Packit ae235b
Packit ae235b
/* This module contains global variables that are exported by the PCRE library.
Packit ae235b
PCRE is thread-clean and doesn't use any global variables in the normal sense.
Packit ae235b
However, it calls memory allocation and freeing functions via the four
Packit ae235b
indirections below, and it can optionally do callouts, using the fifth
Packit ae235b
indirection. These values can be changed by the caller, but are shared between
Packit ae235b
all threads.
Packit ae235b
Packit ae235b
For MS Visual Studio and Symbian OS, there are problems in initializing these
Packit ae235b
variables to non-local functions. In these cases, therefore, an indirection via
Packit ae235b
a local function is used.
Packit ae235b
Packit ae235b
Also, when compiling for Virtual Pascal, things are done differently, and
Packit ae235b
global variables are not used. */
Packit ae235b
Packit ae235b
#include "config.h"
Packit ae235b
Packit ae235b
#include "pcre_internal.h"
Packit ae235b
Packit ae235b
#ifdef GLIB_COMPILATION
Packit ae235b
#include "gmem.h"
Packit ae235b
#else
Packit ae235b
#include <glib.h>
Packit ae235b
#endif /* GLIB_COMPILATION */
Packit ae235b
Packit ae235b
#if defined _MSC_VER || defined  __SYMBIAN32__
Packit ae235b
static void* LocalPcreMalloc(size_t aSize)
Packit ae235b
  {
Packit ae235b
  return malloc(aSize);
Packit ae235b
  }
Packit ae235b
static void LocalPcreFree(void* aPtr)
Packit ae235b
  {
Packit ae235b
  free(aPtr);
Packit ae235b
  }
Packit ae235b
PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = LocalPcreMalloc;
Packit ae235b
PCRE_EXP_DATA_DEFN void  (*PUBL(free))(void *) = LocalPcreFree;
Packit ae235b
PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = LocalPcreMalloc;
Packit ae235b
PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = LocalPcreFree;
Packit ae235b
PCRE_EXP_DATA_DEFN int   (*PUBL(callout))(PUBL(callout_block) *) = NULL;
Packit ae235b
Packit ae235b
#elif !defined VPCOMPAT
Packit ae235b
PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = g_try_malloc;
Packit ae235b
PCRE_EXP_DATA_DEFN void  (*PUBL(free))(void *) = g_free;
Packit ae235b
PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = g_try_malloc;
Packit ae235b
PCRE_EXP_DATA_DEFN void  (*PUBL(stack_free))(void *) = g_free;
Packit ae235b
PCRE_EXP_DATA_DEFN int   (*PUBL(callout))(PUBL(callout_block) *) = NULL;
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* End of pcre_globals.c */