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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
0fb81c1d
Commit
0fb81c1d
authored
Apr 26, 2006
by
osku
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mem_heap_dup().
parent
66946183
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
include/mem0mem.h
include/mem0mem.h
+13
-2
mem/mem0mem.c
mem/mem0mem.c
+17
-4
No files found.
include/mem0mem.h
View file @
0fb81c1d
...
...
@@ -297,8 +297,8 @@ char*
mem_heap_strdup
(
/*============*/
/* out, own: a copy of the string */
mem_heap_t
*
heap
,
/* in: memory heap where string is allocated */
const
char
*
str
);
/* in: string to be copied */
mem_heap_t
*
heap
,
/* in: memory heap where string is allocated */
const
char
*
str
);
/* in: string to be copied */
/**************************************************************************
Makes a NUL-terminated copy of a nonterminated string,
allocated from a memory heap. */
...
...
@@ -322,6 +322,17 @@ 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. */
void
*
mem_heap_dup
(
/*=========*/
/* out, own: a copy of the data */
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 */
#ifdef MEM_PERIODIC_CHECK
/**********************************************************************
Goes through the list of all allocated mem blocks, checks their magic
...
...
mem/mem0mem.c
View file @
0fb81c1d
...
...
@@ -107,11 +107,24 @@ char*
mem_heap_strdup
(
/*============*/
/* out, own: a copy of the string */
mem_heap_t
*
heap
,
/* in: memory heap where string is allocated */
const
char
*
str
)
/* in: string to be copied */
mem_heap_t
*
heap
,
/* in: memory heap where string is allocated */
const
char
*
str
)
/* in: string to be copied */
{
return
(
mem_heap_dup
(
heap
,
str
,
strlen
(
str
)
+
1
));
}
/**************************************************************************
Duplicate a block of data, allocated from a memory heap. */
void
*
mem_heap_dup
(
/*=========*/
/* out, own: a copy of the data */
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 */
{
ulint
len
=
strlen
(
str
)
+
1
;
return
(
memcpy
(
mem_heap_alloc
(
heap
,
len
),
str
,
len
));
return
(
memcpy
(
mem_heap_alloc
(
heap
,
len
),
data
,
len
));
}
/**************************************************************************
...
...
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