Merge lp:~laurynas-biveinis/percona-server/bug1185686-5.6 into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Merged at revision: 371
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1185686-5.6
Merge into: lp:percona-server/5.6
Diff against target: 94 lines (+53/-2)
3 files modified
Percona-Server/storage/innobase/include/ut0mem.h (+16/-0)
Percona-Server/storage/innobase/trx/trx0trx.cc (+2/-2)
Percona-Server/storage/innobase/ut/ut0mem.cc (+35/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1185686-5.6
Reviewer Review Type Date Requested Status
Vlad Lesin (community) Approve
Review via email: mp+166686@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vlad Lesin (vlad-lesin) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/storage/innobase/include/ut0mem.h'
2--- Percona-Server/storage/innobase/include/ut0mem.h 2011-12-28 10:40:55 +0000
3+++ Percona-Server/storage/innobase/include/ut0mem.h 2013-05-31 09:23:32 +0000
4@@ -92,6 +92,22 @@
5 Allocates memory. */
6 #define ut_malloc(n) ut_malloc_low(n, TRUE)
7 /**********************************************************************//**
8+Allocates cleared memory, provides calloc()-like interface.
9+@return own: allocated memory */
10+UNIV_INTERN
11+void*
12+ut_calloc_low(
13+/*==========*/
14+ ulint n, /*!< in: number of elements */
15+ ulint c, /*!< in: size of an element */
16+ ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if
17+ the memory cannot be allocated */
18+ __attribute__((malloc));
19+/**********************************************************************//**
20+Allocates cleared memory, provides calloc()-like interface.
21+@return own: allocated memory */
22+#define ut_calloc(n, c) ut_calloc_low(n, c, TRUE)
23+/**********************************************************************//**
24 Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
25 a nop. */
26 UNIV_INTERN
27
28=== modified file 'Percona-Server/storage/innobase/trx/trx0trx.cc'
29--- Percona-Server/storage/innobase/trx/trx0trx.cc 2013-05-31 08:06:00 +0000
30+++ Percona-Server/storage/innobase/trx/trx0trx.cc 2013-05-31 09:23:32 +0000
31@@ -219,7 +219,7 @@
32 mem_heap_t* heap;
33 ib_alloc_t* heap_alloc;
34
35- trx = static_cast<trx_t*>(mem_zalloc(sizeof(*trx)));
36+ trx = static_cast<trx_t*>(ut_calloc(1, sizeof(*trx)));
37
38 mutex_create(trx_mutex_key, &trx->mutex, SYNC_TRX);
39
40@@ -375,7 +375,7 @@
41
42 read_view_free(trx->prebuilt_view);
43
44- mem_free(trx);
45+ ut_free(trx);
46 }
47
48 /********************************************************************//**
49
50=== modified file 'Percona-Server/storage/innobase/ut/ut0mem.cc'
51--- Percona-Server/storage/innobase/ut/ut0mem.cc 2012-08-30 07:46:21 +0000
52+++ Percona-Server/storage/innobase/ut/ut0mem.cc 2013-05-31 09:23:32 +0000
53@@ -206,6 +206,41 @@
54 }
55
56 /**********************************************************************//**
57+Allocates cleared memory, provides calloc()-like interface.
58+@return own: allocated memory */
59+UNIV_INTERN
60+void*
61+ut_calloc_low(
62+/*==========*/
63+ ulint n, /*!< in: number of elements */
64+ ulint c, /*!< in: size of an element */
65+ ibool assert_on_error) /*!< in: if TRUE, we crash mysqld if
66+ the memory cannot be allocated */
67+{
68+ void* ret;
69+
70+ if (UNIV_LIKELY(srv_use_sys_malloc)) {
71+
72+ ret = calloc(n, c);
73+ ut_a(ret || !assert_on_error);
74+
75+ return ret;
76+ }
77+
78+ ret = ut_malloc(n * c);
79+
80+ if (UNIV_LIKELY(ret != NULL)) {
81+
82+ memset(ret, 0, n * c);
83+ } else {
84+
85+ ut_a(!assert_on_error);
86+ }
87+
88+ return ret;
89+}
90+
91+/**********************************************************************//**
92 Frees a memory block allocated with ut_malloc. Freeing a NULL pointer is
93 a nop. */
94 UNIV_INTERN

Subscribers

People subscribed via source and target branches