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
8c29885e
Unverified
Commit
8c29885e
authored
Sep 27, 2021
by
Edward Thomson
Committed by
GitHub
Sep 27, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6076 from libgit2/ethomson/oidarray_dispose
oidarray: introduce `git_oidarray_dispose`
parents
b6449de3
0bd132ab
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
13 deletions
+43
-13
include/git2/deprecated.h
+24
-0
include/git2/oidarray.h
+5
-8
src/merge.c
+1
-1
src/oidarray.c
+10
-1
tests/revwalk/mergebase.c
+3
-3
No files found.
include/git2/deprecated.h
View file @
8c29885e
...
...
@@ -779,6 +779,30 @@ GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
/**@}*/
/** @name Deprecated OID Array Functions
*
* These types are retained for backward compatibility. The newer
* versions of these values should be preferred in all new code.
*
* There is no plan to remove these backward compatibility values at
* this time.
*/
/**@{*/
/**
* Free the memory referred to by the git_oidarray. This is an alias of
* `git_oidarray_dispose` and is preserved for backward compatibility.
*
* This function is deprecated, but there is no plan to remove this
* function at this time.
*
* @deprecated Use git_oidarray_dispose
* @see git_oidarray_dispose
*/
GIT_EXTERN
(
void
)
git_oidarray_free
(
git_oidarray
*
array
);
/**@}*/
/** @name Deprecated Transfer Progress Types
*
* These types are retained for backward compatibility. The newer
...
...
include/git2/oidarray.h
View file @
8c29885e
...
...
@@ -19,19 +19,16 @@ typedef struct git_oidarray {
}
git_oidarray
;
/**
* Free the OID array
*
* This method must (and must only) be called on `git_oidarray`
* objects where the array is allocated by the library. Not doing so,
* will result in a memory leak.
* Free the object IDs contained in an oid_array. This method should
* be called on `git_oidarray` objects that were provided by the
* library. Not doing so will result in a memory leak.
*
* This does not free the `git_oidarray` itself, since the library will
* never allocate that object directly itself (it is more commonly embedded
* inside another struct or created on the stack).
* never allocate that object directly itself.
*
* @param array git_oidarray from which to free oid data
*/
GIT_EXTERN
(
void
)
git_oidarray_
fre
e
(
git_oidarray
*
array
);
GIT_EXTERN
(
void
)
git_oidarray_
dispos
e
(
git_oidarray
*
array
);
/** @} */
GIT_END_DECL
...
...
src/merge.c
View file @
8c29885e
...
...
@@ -2369,7 +2369,7 @@ done:
git_annotated_commit_free
(
other
);
git_annotated_commit_free
(
new_base
);
git_oidarray_
fre
e
(
&
bases
);
git_oidarray_
dispos
e
(
&
bases
);
git_array_clear
(
head_ids
);
return
error
;
}
...
...
src/oidarray.c
View file @
8c29885e
...
...
@@ -10,7 +10,7 @@
#include "git2/oidarray.h"
#include "array.h"
void
git_oidarray_
fre
e
(
git_oidarray
*
arr
)
void
git_oidarray_
dispos
e
(
git_oidarray
*
arr
)
{
git__free
(
arr
->
ids
);
}
...
...
@@ -32,3 +32,12 @@ void git_oidarray__reverse(git_oidarray *arr)
git_oid_cpy
(
&
arr
->
ids
[(
arr
->
count
-
1
)
-
i
],
&
tmp
);
}
}
#ifndef GIT_DEPRECATE_HARD
void
git_oidarray_free
(
git_oidarray
*
arr
)
{
git_oidarray_dispose
(
arr
);
}
#endif
tests/revwalk/mergebase.c
View file @
8c29885e
...
...
@@ -150,7 +150,7 @@ void test_revwalk_mergebase__multiple_merge_bases(void)
cl_assert_equal_oid
(
&
expected1
,
&
result
.
ids
[
0
]);
cl_assert_equal_oid
(
&
expected2
,
&
result
.
ids
[
1
]);
git_oidarray_
fre
e
(
&
result
);
git_oidarray_
dispos
e
(
&
result
);
}
void
test_revwalk_mergebase__multiple_merge_bases_many_commits
(
void
)
...
...
@@ -170,7 +170,7 @@ void test_revwalk_mergebase__multiple_merge_bases_many_commits(void)
cl_assert_equal_oid
(
&
expected1
,
&
result
.
ids
[
0
]);
cl_assert_equal_oid
(
&
expected2
,
&
result
.
ids
[
1
]);
git_oidarray_
fre
e
(
&
result
);
git_oidarray_
dispos
e
(
&
result
);
git__free
(
input
);
}
...
...
@@ -509,6 +509,6 @@ void test_revwalk_mergebase__remove_redundant(void)
cl_assert_equal_i
(
1
,
result
.
count
);
cl_assert_equal_oid
(
&
base
,
&
result
.
ids
[
0
]);
git_oidarray_
fre
e
(
&
result
);
git_oidarray_
dispos
e
(
&
result
);
git_repository_free
(
repo
);
}
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