Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
fe47aee3
Commit
fe47aee3
authored
Sep 04, 2017
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inline definition of mem_heap_dup(), mem_heap_strdup(), mem_heap_strdupl()
parent
83f9422f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
66 deletions
+30
-66
storage/innobase/include/mem0mem.h
storage/innobase/include/mem0mem.h
+30
-24
storage/innobase/include/mem0mem.ic
storage/innobase/include/mem0mem.ic
+0
-17
storage/innobase/mem/mem0mem.cc
storage/innobase/mem/mem0mem.cc
+0
-25
No files found.
storage/innobase/include/mem0mem.h
View file @
fe47aee3
...
...
@@ -294,26 +294,42 @@ mem_strdupl(
const
char
*
str
,
/*!< in: string to be copied */
ulint
len
);
/*!< in: length of str, in bytes */
/** Duplicates a NUL-terminated string, allocated from a memory heap.
/** Duplicate a block of data, allocated from a memory heap.
@param[in] heap memory heap where string is allocated
@param[in] data block of data to be copied
@param[in] len length of data, in bytes
@return own: a copy of data */
inline
void
*
mem_heap_dup
(
mem_heap_t
*
heap
,
const
void
*
data
,
size_t
len
)
{
return
(
memcpy
(
mem_heap_alloc
(
heap
,
len
),
data
,
len
));
}
/** Duplicate a NUL-terminated string, allocated from a memory heap.
@param[in] heap memory heap where string is allocated
@param[in] str string to be copied
@return own: a copy of the string */
inline
char
*
mem_heap_strdup
(
mem_heap_t
*
heap
,
const
char
*
str
);
mem_heap_strdup
(
mem_heap_t
*
heap
,
const
char
*
str
)
{
return
(
static_cast
<
char
*>
(
mem_heap_dup
(
heap
,
str
,
strlen
(
str
)
+
1
)));
}
/**********************************************************************//**
Makes a NUL-terminated copy of a nonterminated string,
allocated from a memory heap.
@return own: a copy of the string */
UNIV_INLINE
/** Duplicate a string, allocated from a memory heap.
@param[in] heap memory heap where string is allocated
@param[in] str string to be copied
@param[in] len length of str, in bytes
@return own: a NUL-terminated copy of str */
inline
char
*
mem_heap_strdupl
(
/*=============*/
mem_heap_t
*
heap
,
/*!< in: memory heap where string is allocated */
const
char
*
str
,
/*!< in: string to be copied */
ulint
len
);
/*!< in: length of str, in bytes */
mem_heap_strdupl
(
mem_heap_t
*
heap
,
const
char
*
str
,
size_t
len
)
{
char
*
s
=
static_cast
<
char
*>
(
mem_heap_alloc
(
heap
,
len
+
1
));
s
[
len
]
=
0
;
return
(
static_cast
<
char
*>
(
memcpy
(
s
,
str
,
len
)));
}
/**********************************************************************//**
Concatenate two strings and return the result, using a memory heap.
...
...
@@ -325,16 +341,6 @@ mem_heap_strcat(
const
char
*
s1
,
/*!< in: string 1 */
const
char
*
s2
);
/*!< in: string 2 */
/**********************************************************************//**
Duplicate a block of data, allocated from a memory heap.
@return own: a copy of the data */
void
*
mem_heap_dup
(
/*=========*/
mem_heap_t
*
heap
,
/*!< in: memory heap where copy is allocated */
const
void
*
data
,
/*!< in: data to be copied */
ulint
len
);
/*!< in: length of data, in bytes */
/****************************************************************//**
A simple sprintf replacement that dynamically allocates the space for the
formatted string from the given heap. This supports a very limited set of
...
...
storage/innobase/include/mem0mem.ic
View file @
fe47aee3
...
...
@@ -586,20 +586,3 @@ mem_strdupl(
s[len] = 0;
return(static_cast<char*>(memcpy(s, str, len)));
}
/**********************************************************************//**
Makes a NUL-terminated copy of a nonterminated string,
allocated from a memory heap.
@return own: a copy of the string */
UNIV_INLINE
char*
mem_heap_strdupl(
/*=============*/
mem_heap_t* heap, /*!< in: memory heap where string is allocated */
const char* str, /*!< in: string to be copied */
ulint len) /*!< in: length of str, in bytes */
{
char* s = (char*) mem_heap_alloc(heap, len + 1);
s[len] = 0;
return((char*) memcpy(s, str, len));
}
storage/innobase/mem/mem0mem.cc
View file @
fe47aee3
...
...
@@ -31,31 +31,6 @@ Created 6/9/1994 Heikki Tuuri
#include "srv0srv.h"
#include <stdarg.h>
/** Duplicates a NUL-terminated string, allocated from a memory heap.
@param[in] heap, memory heap where string is allocated
@param[in] str) string to be copied
@return own: a copy of the string */
char
*
mem_heap_strdup
(
mem_heap_t
*
heap
,
const
char
*
str
)
{
return
(
static_cast
<
char
*>
(
mem_heap_dup
(
heap
,
str
,
strlen
(
str
)
+
1
)));
}
/**********************************************************************//**
Duplicate a block of data, allocated from a memory heap.
@return own: a copy of the data */
void
*
mem_heap_dup
(
/*=========*/
mem_heap_t
*
heap
,
/*!< in: memory heap where copy is allocated */
const
void
*
data
,
/*!< in: data to be copied */
ulint
len
)
/*!< in: length of data, in bytes */
{
return
(
memcpy
(
mem_heap_alloc
(
heap
,
len
),
data
,
len
));
}
/**********************************************************************//**
Concatenate two strings and return the result, using a memory heap.
@return own: the result */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment