Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
6adcb5f3
Commit
6adcb5f3
authored
May 17, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: Implement git__strndup
parent
b3d94069
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
src/util.h
+19
-0
No files found.
src/util.h
View file @
6adcb5f3
...
...
@@ -34,6 +34,25 @@ GIT_INLINE(char *) git__strdup(const char *str)
return
ptr
;
}
GIT_INLINE
(
char
*
)
git__strndup
(
const
char
*
str
,
size_t
n
)
{
size_t
length
;
char
*
ptr
;
length
=
strlen
(
str
);
if
(
n
<
length
)
length
=
n
;
ptr
=
malloc
(
length
+
1
);
if
(
!
ptr
)
git__throw
(
GIT_ENOMEM
,
"Out of memory. Failed to duplicate string"
);
memcpy
(
ptr
,
str
,
length
);
ptr
[
length
]
=
0
;
return
ptr
;
}
GIT_INLINE
(
void
*
)
git__realloc
(
void
*
ptr
,
size_t
size
)
{
void
*
new_ptr
=
realloc
(
ptr
,
size
);
...
...
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