Skip to content

Commit 8c29885

Browse files
authored
Merge pull request libgit2#6076 from libgit2/ethomson/oidarray_dispose
oidarray: introduce `git_oidarray_dispose`
2 parents b6449de + 0bd132a commit 8c29885

File tree

5 files changed

+77
-47
lines changed

5 files changed

+77
-47
lines changed

include/git2/deprecated.h

+24
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,30 @@ GIT_EXTERN(int) git_oid_iszero(const git_oid *id);
779779

780780
/**@}*/
781781

782+
/** @name Deprecated OID Array Functions
783+
*
784+
* These types are retained for backward compatibility. The newer
785+
* versions of these values should be preferred in all new code.
786+
*
787+
* There is no plan to remove these backward compatibility values at
788+
* this time.
789+
*/
790+
/**@{*/
791+
792+
/**
793+
* Free the memory referred to by the git_oidarray. This is an alias of
794+
* `git_oidarray_dispose` and is preserved for backward compatibility.
795+
*
796+
* This function is deprecated, but there is no plan to remove this
797+
* function at this time.
798+
*
799+
* @deprecated Use git_oidarray_dispose
800+
* @see git_oidarray_dispose
801+
*/
802+
GIT_EXTERN(void) git_oidarray_free(git_oidarray *array);
803+
804+
/**@}*/
805+
782806
/** @name Deprecated Transfer Progress Types
783807
*
784808
* These types are retained for backward compatibility. The newer

include/git2/oidarray.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,16 @@ typedef struct git_oidarray {
1919
} git_oidarray;
2020

2121
/**
22-
* Free the OID array
23-
*
24-
* This method must (and must only) be called on `git_oidarray`
25-
* objects where the array is allocated by the library. Not doing so,
26-
* will result in a memory leak.
22+
* Free the object IDs contained in an oid_array. This method should
23+
* be called on `git_oidarray` objects that were provided by the
24+
* library. Not doing so will result in a memory leak.
2725
*
2826
* This does not free the `git_oidarray` itself, since the library will
29-
* never allocate that object directly itself (it is more commonly embedded
30-
* inside another struct or created on the stack).
27+
* never allocate that object directly itself.
3128
*
3229
* @param array git_oidarray from which to free oid data
3330
*/
34-
GIT_EXTERN(void) git_oidarray_free(git_oidarray *array);
31+
GIT_EXTERN(void) git_oidarray_dispose(git_oidarray *array);
3532

3633
/** @} */
3734
GIT_END_DECL

src/merge.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ static int compute_base(
23692369

23702370
git_annotated_commit_free(other);
23712371
git_annotated_commit_free(new_base);
2372-
git_oidarray_free(&bases);
2372+
git_oidarray_dispose(&bases);
23732373
git_array_clear(head_ids);
23742374
return error;
23752375
}

src/oidarray.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "git2/oidarray.h"
1111
#include "array.h"
1212

13-
void git_oidarray_free(git_oidarray *arr)
13+
void git_oidarray_dispose(git_oidarray *arr)
1414
{
1515
git__free(arr->ids);
1616
}
@@ -32,3 +32,12 @@ void git_oidarray__reverse(git_oidarray *arr)
3232
git_oid_cpy(&arr->ids[(arr->count-1)-i], &tmp);
3333
}
3434
}
35+
36+
#ifndef GIT_DEPRECATE_HARD
37+
38+
void git_oidarray_free(git_oidarray *arr)
39+
{
40+
git_oidarray_dispose(arr);
41+
}
42+
43+
#endif

tests/revwalk/mergebase.c

+37-37
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void test_revwalk_mergebase__multiple_merge_bases(void)
150150
cl_assert_equal_oid(&expected1, &result.ids[0]);
151151
cl_assert_equal_oid(&expected2, &result.ids[1]);
152152

153-
git_oidarray_free(&result);
153+
git_oidarray_dispose(&result);
154154
}
155155

156156
void test_revwalk_mergebase__multiple_merge_bases_many_commits(void)
@@ -170,7 +170,7 @@ void test_revwalk_mergebase__multiple_merge_bases_many_commits(void)
170170
cl_assert_equal_oid(&expected1, &result.ids[0]);
171171
cl_assert_equal_oid(&expected2, &result.ids[1]);
172172

173-
git_oidarray_free(&result);
173+
git_oidarray_dispose(&result);
174174
git__free(input);
175175
}
176176

@@ -186,7 +186,7 @@ void test_revwalk_mergebase__no_off_by_one_missing(void)
186186
static void assert_mergebase_many(const char *expected_sha, int count, ...)
187187
{
188188
va_list ap;
189-
int i;
189+
int i;
190190
git_oid *oids;
191191
git_oid oid, expected;
192192
char *partial_oid;
@@ -376,9 +376,9 @@ void test_revwalk_mergebase__octopus_merge_branch(void)
376376
* * commit 8496071c1b46c854b31185ea97743be6a8774479
377377
* Author: Scott Chacon <[email protected]>
378378
* Date: Sat May 8 16:13:06 2010 -0700
379-
*
379+
*
380380
* testing
381-
*
381+
*
382382
* * commit 41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9
383383
* | Author: Scott Chacon <[email protected]>
384384
* | Date: Tue May 11 13:40:41 2010 -0700
@@ -388,7 +388,7 @@ void test_revwalk_mergebase__octopus_merge_branch(void)
388388
* * commit 5001298e0c09ad9c34e4249bc5801c75e9754fa5
389389
* Author: Scott Chacon <[email protected]>
390390
* Date: Tue May 11 13:40:23 2010 -0700
391-
*
391+
*
392392
* packed commit one
393393
*/
394394

@@ -398,94 +398,94 @@ void test_revwalk_mergebase__octopus_merge_branch(void)
398398
* |\ Merge: c37a783 2224e19
399399
* | | Author: Scott J. Goldman <[email protected]>
400400
* | | Date: Tue Nov 27 20:31:04 2012 -0800
401-
* | |
401+
* | |
402402
* | | Merge branch 'first-branch' into second-branch
403-
* | |
403+
* | |
404404
* | * commit 2224e191514cb4bd8c566d80dac22dfcb1e9bb83
405405
* | | Author: Scott J. Goldman <[email protected]>
406406
* | | Date: Tue Nov 27 20:28:51 2012 -0800
407-
* | |
407+
* | |
408408
* | | j
409-
* | |
409+
* | |
410410
* | * commit a41a49f8f5cd9b6cb14a076bf8394881ed0b4d19
411411
* | | Author: Scott J. Goldman <[email protected]>
412412
* | | Date: Tue Nov 27 20:28:39 2012 -0800
413-
* | |
413+
* | |
414414
* | | i
415-
* | |
415+
* | |
416416
* | * commit 82bf9a1a10a4b25c1f14c9607b60970705e92545
417417
* | | Author: Scott J. Goldman <[email protected]>
418418
* | | Date: Tue Nov 27 20:28:28 2012 -0800
419-
* | |
419+
* | |
420420
* | | h
421-
* | |
421+
* | |
422422
* * | commit c37a783c20d92ac92362a78a32860f7eebf938ef
423423
* | | Author: Scott J. Goldman <[email protected]>
424424
* | | Date: Tue Nov 27 20:30:57 2012 -0800
425-
* | |
425+
* | |
426426
* | | n
427-
* | |
427+
* | |
428428
* * | commit 8b82fb1794cb1c8c7f172ec730a4c2db0ae3e650
429429
* | | Author: Scott J. Goldman <[email protected]>
430430
* | | Date: Tue Nov 27 20:30:43 2012 -0800
431-
* | |
431+
* | |
432432
* | | m
433-
* | |
433+
* | |
434434
* * | commit 6ab5d28acbf3c3bdff276f7ccfdf29c1520e542f
435435
* | | Author: Scott J. Goldman <[email protected]>
436436
* | | Date: Tue Nov 27 20:30:38 2012 -0800
437-
* | |
437+
* | |
438438
* | | l
439-
* | |
439+
* | |
440440
* * | commit 7b8c336c45fc6895c1c60827260fe5d798e5d247
441441
* | | Author: Scott J. Goldman <[email protected]>
442442
* | | Date: Tue Nov 27 20:30:24 2012 -0800
443-
* | |
443+
* | |
444444
* | | k
445-
* | |
445+
* | |
446446
* | | * commit 1c30b88f5f3ee66d78df6520a7de9e89b890818b
447447
* | | | Author: Scott J. Goldman <[email protected]>
448448
* | | | Date: Tue Nov 27 20:28:10 2012 -0800
449-
* | | |
449+
* | | |
450450
* | | | e
451-
* | | |
451+
* | | |
452452
* | | * commit 42b7311aa626e712891940c1ec5d5cba201946a4
453453
* | | | Author: Scott J. Goldman <[email protected]>
454454
* | | | Date: Tue Nov 27 20:28:06 2012 -0800
455-
* | | |
455+
* | | |
456456
* | | | d
457-
* | | |
457+
* | | |
458458
* | | * commit a953a018c5b10b20c86e69fef55ebc8ad4c5a417
459459
* | | |\ Merge: bd1732c cdf97fd
460460
* | | |/ Author: Scott J. Goldman <[email protected]>
461461
* | |/| Date: Tue Nov 27 20:26:43 2012 -0800
462-
* | | |
462+
* | | |
463463
* | | | Merge branch 'first-branch'
464-
* | | |
464+
* | | |
465465
* | * | commit cdf97fd3bb48eb3827638bb33d208f5fd32d0aa6
466466
* | | | Author: Scott J. Goldman <[email protected]>
467467
* | | | Date: Tue Nov 27 20:24:46 2012 -0800
468-
* | | |
468+
* | | |
469469
* | | | g
470-
* | | |
470+
* | | |
471471
* | * | commit ef0488f0b722f0be8bcb90a7730ac7efafd1d694
472472
* | | | Author: Scott J. Goldman <[email protected]>
473473
* | | | Date: Tue Nov 27 20:24:39 2012 -0800
474-
* | | |
474+
* | | |
475475
* | | | f
476-
* | | |
476+
* | | |
477477
* | | * commit bd1732c43c68d712ad09e1d872b9be6d4b9efdc4
478478
* | |/ Author: Scott J. Goldman <[email protected]>
479479
* | | Date: Tue Nov 27 17:43:58 2012 -0800
480-
* | |
480+
* | |
481481
* | | c
482-
* | |
482+
* | |
483483
* | * commit 0c8a3f1f3d5f421cf83048c7c73ee3b55a5e0f29
484484
* |/ Author: Scott J. Goldman <[email protected]>
485485
* | Date: Tue Nov 27 17:43:48 2012 -0800
486-
* |
486+
* |
487487
* | b
488-
* |
488+
* |
489489
* * commit 1f4c0311a24b63f6fc209a59a1e404942d4a5006
490490
* Author: Scott J. Goldman <[email protected]>
491491
* Date: Tue Nov 27 17:43:41 2012 -0800
@@ -509,6 +509,6 @@ void test_revwalk_mergebase__remove_redundant(void)
509509
cl_assert_equal_i(1, result.count);
510510
cl_assert_equal_oid(&base, &result.ids[0]);
511511

512-
git_oidarray_free(&result);
512+
git_oidarray_dispose(&result);
513513
git_repository_free(repo);
514514
}

0 commit comments

Comments
 (0)