MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stub_pfs_global.h
1 /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 #include <my_global.h>
17 #include <my_sys.h>
18 #include <pfs_global.h>
19 #include <string.h>
20 
21 bool pfs_initialized= false;
22 
23 bool stub_alloc_always_fails= true;
24 int stub_alloc_fails_after_count= 0;
25 
26 void *pfs_malloc(size_t size, myf)
27 {
28  if (stub_alloc_always_fails)
29  return NULL;
30 
31  if (--stub_alloc_fails_after_count <= 0)
32  return NULL;
33 
34  void *ptr= malloc(size);
35  if (ptr != NULL)
36  memset(ptr, 0, size);
37  return ptr;
38 }
39 
40 void pfs_free(void *ptr)
41 {
42  if (ptr != NULL)
43  free(ptr);
44 }
45 
46 void pfs_print_error(const char *format, ...)
47 {
48 }
49