Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\assoc_array.c Create Date:2022-07-28 06:54:16
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Destructively iterate over an associative array. The caller must prevent* other simultaneous accesses.

Proto:static void assoc_array_destroy_subtree(struct assoc_array_ptr *root, const struct assoc_array_ops *ops)

Type:void

Parameter:

TypeParameterName
struct assoc_array_ptr *root
const struct assoc_array_ops *ops
348  struct assoc_array_ptr * cursor, * parent = NULL
349  slot = -1
351  pr_devel("-->%s()\n", __func__)
353  cursor = root
354  If Not cursor Then
355  pr_devel("empty\n")
356  Return
359  move_to_meta :
360  If assoc_array_ptr_is_shortcut(cursor) Then
362  pr_devel("[%d] shortcut\n", slot)
363  BUG_ON(!assoc_array_ptr_is_shortcut(cursor))
364  shortcut = assoc_array_ptr_to_shortcut(cursor)
365  BUG_ON(back_pointer != parent)
366  BUG_ON(slot != - 1 && parent_slot != slot)
367  parent = cursor
368  cursor = next_node
369  slot = -1
370  BUG_ON(!assoc_array_ptr_is_node(cursor))
373  pr_devel("[%d] node\n", slot)
374  node = assoc_array_ptr_to_node(cursor)
375  BUG_ON(back_pointer != parent)
376  BUG_ON(slot != - 1 && parent_slot != slot)
377  slot = 0
379  continue_node :
380  pr_devel("Node %p [back=%p]\n", node, back_pointer)
381  When slot < Number of slots per node cycle
382  ptr = slots[slot]
383  If Not ptr Then Continue
385  If assoc_array_ptr_is_meta(ptr) Then
386  parent = cursor
387  cursor = ptr
388  Go to move_to_meta
391  If ops Then
392  pr_devel("[%d] free leaf\n", slot)
397  parent = back_pointer
398  slot = parent_slot
399  pr_devel("free node\n")
400  kfree(node)
401  If Not parent Then Return
406  If assoc_array_ptr_is_shortcut(parent) Then
407  shortcut = assoc_array_ptr_to_shortcut(parent)
408  BUG_ON(next_node != cursor)
409  cursor = parent
410  parent = back_pointer
411  slot = parent_slot
412  pr_devel("free shortcut\n")
413  kfree(shortcut)
414  If Not parent Then Return
417  BUG_ON(!assoc_array_ptr_is_node(parent))
421  pr_devel("ascend to %p[%d]\n", parent, slot)
422  cursor = parent
423  node = assoc_array_ptr_to_node(cursor)
424  slot++
425  Go to continue_node
Caller
NameDescribe
assoc_array_destroyassoc_array_destroy - Destroy an associative array*@array: The array to destroy.*@ops: The operations to use.* Discard all metadata and free all objects in an associative array. The* array will be empty and ready to use again upon completion. This function
assoc_array_rcu_cleanup
assoc_array_gcassoc_array_gc - Garbage collect an associative array