Commit bf8a536
zram: use statically allocated compression algorithm names
Currently, zram dynamically allocates memory for compressor algorithm names
when they are set by the user. This requires careful memory management,
including explicit `kfree` calls and special handling to avoid freeing
statically defined default compressor names.
This patch refactors the way zram handles compression algorithm names.
Instead of storing dynamically allocated copies, `zram->comp_algs` will now
store pointers directly to the static name strings defined within the
`zcomp_ops` backend structures, thereby removing the need for conditional
`kfree` calls.
Signed-off-by: gao xu <gaoxu2@honor.com>1 parent bbb3394 commit bf8a536
3 files changed
Lines changed: 13 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1637 | 1637 | | |
1638 | 1638 | | |
1639 | 1639 | | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | 1640 | | |
1645 | 1641 | | |
1646 | 1642 | | |
1647 | 1643 | | |
1648 | 1644 | | |
1649 | | - | |
| 1645 | + | |
1650 | 1646 | | |
1651 | 1647 | | |
1652 | 1648 | | |
1653 | 1649 | | |
1654 | 1650 | | |
1655 | 1651 | | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
1661 | | - | |
1662 | | - | |
1663 | | - | |
1664 | | - | |
1665 | | - | |
| 1652 | + | |
| 1653 | + | |
1666 | 1654 | | |
1667 | | - | |
1668 | 1655 | | |
1669 | 1656 | | |
1670 | 1657 | | |
1671 | | - | |
1672 | 1658 | | |
1673 | 1659 | | |
1674 | 1660 | | |
1675 | 1661 | | |
1676 | | - | |
| 1662 | + | |
1677 | 1663 | | |
1678 | 1664 | | |
1679 | 1665 | | |
| |||
2851 | 2837 | | |
2852 | 2838 | | |
2853 | 2839 | | |
2854 | | - | |
2855 | | - | |
2856 | | - | |
2857 | | - | |
| 2840 | + | |
2858 | 2841 | | |
2859 | | - | |
2860 | 2842 | | |
2861 | 2843 | | |
2862 | 2844 | | |
| |||
0 commit comments