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
3fa5e577
Commit
3fa5e577
authored
Jan 17, 2018
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: Move xrealloc to common example code
parent
b6720018
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
10 deletions
+15
-10
examples/common.c
+10
-0
examples/common.h
+5
-0
examples/describe.c
+0
-10
No files found.
examples/common.c
View file @
3fa5e577
...
...
@@ -235,3 +235,13 @@ void treeish_to_tree(
git_object_free
(
obj
);
}
void
*
xrealloc
(
void
*
oldp
,
size_t
newsz
)
{
void
*
p
=
realloc
(
oldp
,
newsz
);
if
(
p
==
NULL
)
{
fprintf
(
stderr
,
"Cannot allocate memory, exiting.
\n
"
);
exit
(
1
);
}
return
p
;
}
examples/common.h
View file @
3fa5e577
...
...
@@ -103,3 +103,8 @@ extern int diff_output(
*/
extern
void
treeish_to_tree
(
git_tree
**
out
,
git_repository
*
repo
,
const
char
*
treeish
);
/**
* A realloc that exits on failure
*/
extern
void
*
xrealloc
(
void
*
oldp
,
size_t
newsz
);
examples/describe.c
View file @
3fa5e577
...
...
@@ -47,16 +47,6 @@ typedef struct {
typedef
struct
args_info
args_info
;
static
void
*
xrealloc
(
void
*
oldp
,
size_t
newsz
)
{
void
*
p
=
realloc
(
oldp
,
newsz
);
if
(
p
==
NULL
)
{
fprintf
(
stderr
,
"Cannot allocate memory, exiting.
\n
"
);
exit
(
1
);
}
return
p
;
}
static
void
opts_add_commit
(
describe_options
*
opts
,
const
char
*
commit
)
{
size_t
sz
;
...
...
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