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
c4beee76
Commit
c4beee76
authored
Feb 01, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce git__substrdup
parent
8c36a3cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
10 deletions
+14
-10
src/netops.c
+5
-5
src/util.h
+9
-5
No files found.
src/netops.c
View file @
c4beee76
...
@@ -606,26 +606,26 @@ int gitno_extract_url_parts(
...
@@ -606,26 +606,26 @@ int gitno_extract_url_parts(
start
=
url
;
start
=
url
;
if
(
at
&&
at
<
slash
)
{
if
(
at
&&
at
<
slash
)
{
start
=
at
+
1
;
start
=
at
+
1
;
*
username
=
git__s
trn
dup
(
url
,
at
-
url
);
*
username
=
git__s
ubstr
dup
(
url
,
at
-
url
);
}
}
if
(
colon
&&
colon
<
at
)
{
if
(
colon
&&
colon
<
at
)
{
git__free
(
*
username
);
git__free
(
*
username
);
*
username
=
git__s
trn
dup
(
url
,
colon
-
url
);
*
username
=
git__s
ubstr
dup
(
url
,
colon
-
url
);
*
password
=
git__s
trn
dup
(
colon
+
1
,
at
-
colon
-
1
);
*
password
=
git__s
ubstr
dup
(
colon
+
1
,
at
-
colon
-
1
);
colon
=
strchr
(
at
,
':'
);
colon
=
strchr
(
at
,
':'
);
}
}
if
(
colon
==
NULL
)
{
if
(
colon
==
NULL
)
{
*
port
=
git__strdup
(
default_port
);
*
port
=
git__strdup
(
default_port
);
}
else
{
}
else
{
*
port
=
git__s
trn
dup
(
colon
+
1
,
slash
-
colon
-
1
);
*
port
=
git__s
ubstr
dup
(
colon
+
1
,
slash
-
colon
-
1
);
}
}
GITERR_CHECK_ALLOC
(
*
port
);
GITERR_CHECK_ALLOC
(
*
port
);
end
=
colon
==
NULL
?
slash
:
colon
;
end
=
colon
==
NULL
?
slash
:
colon
;
*
host
=
git__s
trn
dup
(
start
,
end
-
start
);
*
host
=
git__s
ubstr
dup
(
start
,
end
-
start
);
GITERR_CHECK_ALLOC
(
*
host
);
GITERR_CHECK_ALLOC
(
*
host
);
return
0
;
return
0
;
...
...
src/util.h
View file @
c4beee76
...
@@ -51,11 +51,7 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
...
@@ -51,11 +51,7 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
while
(
length
<
n
&&
str
[
length
])
while
(
length
<
n
&&
str
[
length
])
++
length
;
++
length
;
ptr
=
(
char
*
)
malloc
(
length
+
1
);
ptr
=
(
char
*
)
git__malloc
(
length
+
1
);
if
(
!
ptr
)
{
giterr_set_oom
();
return
NULL
;
}
if
(
length
)
if
(
length
)
memcpy
(
ptr
,
str
,
length
);
memcpy
(
ptr
,
str
,
length
);
...
@@ -65,6 +61,14 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
...
@@ -65,6 +61,14 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
return
ptr
;
return
ptr
;
}
}
/* NOTE: This doesn't do null or '\0' checking. Watch those boundaries! */
GIT_INLINE
(
char
*
)
git__substrdup
(
const
char
*
start
,
size_t
n
)
{
char
*
ptr
=
(
char
*
)
git__calloc
(
n
+
1
,
sizeof
(
char
));
memcpy
(
ptr
,
start
,
n
);
return
ptr
;
}
GIT_INLINE
(
void
*
)
git__realloc
(
void
*
ptr
,
size_t
size
)
GIT_INLINE
(
void
*
)
git__realloc
(
void
*
ptr
,
size_t
size
)
{
{
void
*
new_ptr
=
realloc
(
ptr
,
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