CUBRID Engine  latest
db_json_allocator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #include "db_json_allocator.hpp"
20 
21 #include "error_manager.h"
22 #include "memory_alloc.h"
23 #include "system_parameter.h"
24 
25 void *
27 {
28  if (size) // behavior of malloc(0) is implementation defined.
29  {
30  char *p = (char *) db_private_alloc (NULL, size);
32  {
33  er_print_callstack (ARG_FILE_LINE, "JSON_ALLOC: Traced pointer=%p\n", p);
34  }
35  return p;
36  }
37  else
38  {
39  return NULL; // standardize to returning NULL.
40  }
41 }
42 
43 void *
44 JSON_PRIVATE_ALLOCATOR::Realloc (void *originalPtr, size_t originalSize, size_t newSize)
45 {
46  (void) originalSize;
47  char *p;
48  if (newSize == 0)
49  {
50  db_private_free (NULL, originalPtr);
51  return NULL;
52  }
53  p = (char *) db_private_realloc (NULL, originalPtr, newSize);
55  {
56  er_print_callstack (ARG_FILE_LINE, "Traced pointer=%p\n", p);
57  }
58  return p;
59 }
60 
61 void
63 {
64  db_private_free (NULL, ptr);
65 }
66 
67 const bool JSON_PRIVATE_ALLOCATOR::kNeedFree = true;
void * Realloc(void *originalPtr, size_t originalSize, size_t newSize)
static const bool kNeedFree
#define NULL
Definition: freelistheap.h:34
void * Malloc(size_t size)
#define db_private_free(thrd, ptr)
Definition: memory_alloc.h:229
#define db_private_alloc(thrd, size)
Definition: memory_alloc.h:227
#define ARG_FILE_LINE
Definition: error_manager.h:44
void er_print_callstack(const char *file_name, const int line_no, const char *fmt,...)
bool prm_get_bool_value(PARAM_ID prm_id)
#define db_private_realloc(thrd, ptr, size)
Definition: memory_alloc.h:231
const char ** p
Definition: dynamic_load.c:945
static void Free(void *ptr)