aboutsummaryrefslogtreecommitdiffstats
path: root/t/unit-tests/t-urlmatch-normalization.c
diff options
context:
space:
mode:
authorRubén Justo <rjusto@gmail.com>2024-12-04 23:44:25 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-10 09:07:47 +0900
commit14ef8c04c545d729174839b3ecbad2b5f24b1de6 (patch)
treef8f8700355bba844716e0bb26fec74b91eb52054 /t/unit-tests/t-urlmatch-normalization.c
parentMerge branch 'ps/leakfixes-part-10' into rj/strvec-splice-fix (diff)
downloadgit-14ef8c04c545d729174839b3ecbad2b5f24b1de6.tar.gz
git-14ef8c04c545d729174839b3ecbad2b5f24b1de6.zip
strvec: `strvec_splice()` to a statically initialized vector
We use a singleton empty array to initialize a `struct strvec`; similar to the empty string singleton we use to initialize a `struct strbuf`. Note that an empty strvec instance (with zero elements) does not necessarily need to be an instance initialized with the singleton. Let's refer to strvec instances initialized with the singleton as "empty-singleton" instances. As a side note, this is the current `strvec_pop()`: void strvec_pop(struct strvec *array) { if (!array->nr) return; free((char *)array->v[array->nr - 1]); array->v[array->nr - 1] = NULL; array->nr--; } So, with `strvec_pop()` an instance can become empty but it does not going to be the an "empty-singleton". This "empty-singleton" circumstance requires us to be careful when adding elements to instances. Specifically, when adding the first element: when we detach the strvec instance from the singleton and set the internal pointer in the instance to NULL. After this point we apply `realloc()` on the pointer. We do this in `strvec_push_nodup()`, for example. The recently introduced `strvec_splice()` API is expected to be normally used with non-empty strvec's. However, it can also end up being used with "empty-singleton" strvec's: struct strvec arr = STRVEC_INIT; int a = 0, b = 0; ... no modification to arr, a or b ... const char *rep[] = { "foo" }; strvec_splice(&arr, a, b, rep, ARRAY_SIZE(rep)); So, we'll try to add elements to an "empty-singleton" strvec instance. Avoid misapplying `realloc()` to the singleton in `strvec_splice()` by adding a special case for strvec's initialized with the singleton. Signed-off-by: Rubén Justo <rjusto@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests/t-urlmatch-normalization.c')
0 files changed, 0 insertions, 0 deletions
'>2023-08-31drm/amdgpu: fix VPE front door loading issueLang Yu6-0/+63 2023-08-31drm/amdgpu: add VPE FW version query supportLang Yu2-0/+14 2023-08-31drm/amdgpu: enable VPE for VPE 6.1.0Lang Yu1-0/+19 2023-08-31drm/amdgpu: add user space CS support for VPELang Yu3-0/+9 2023-08-31drm/amdgpu: add PSP loading support for VPELang Yu2-0/+28 2023-08-31drm/amdgpu: add VPE 6.1.0 supportLang Yu6-0/+1019 2023-08-31drm/amdgpu: add nbio 7.11 callback for VPELang Yu1-0/+24 2023-08-31drm/amdgpu: add nbio callback for VPELang Yu1-0/+2 2023-08-31drm/amdgpu: add PSP FW TYPE for VPELang Yu2-0/+8 2023-08-31drm/amdgpu: add UCODE ID for VPELang Yu1-0/+2 2023-08-31drm/amdgpu: add support for VPE firmware name decodingLang Yu1-0/+3 2023-08-31drm/amdgpu: add doorbell index for VPELang Yu2-2/+6