]> git.ipfire.org Git - thirdparty/lxc.git/commit
When an item is added to an array, then the array is realloc()ed (to size+1), 3877/head
authorTomasz Blaszczak <tomasz.blaszczak@consult.red>
Wed, 23 Jun 2021 07:17:05 +0000 (09:17 +0200)
committerTomasz Blaszczak <tomasz.blaszczak@consult.red>
Tue, 29 Jun 2021 06:20:51 +0000 (08:20 +0200)
commitbc5f0449c08cefeae97d3fadc6ec6df0f786d6f0
treeef921c59ad0106d55bd9da84698a2d5cf1f4bb39
parent5364ae41aaa4718853b41dd0d312555867b990f1
When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, memory allocated for that item
should be freed, successive items should be left-shifted and the array
realloc()ed again (size-1).

Additional changes:
- If strdup() fails in add_to_array(), then an array should be
  realloc()ed again to original size.
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.blaszczak@consult.red>
src/lxc/lxccontainer.c