Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4606463416
|
||
|
|
d794a17f8b
|
||
|
|
ab396a2603
|
||
|
|
a6f134eada
|
||
|
|
d3dc97ad2b
|
||
|
|
87adf32143
|
||
|
|
23ed17b814
|
||
|
|
b03033573b
|
||
|
|
31ccf70b9b
|
||
|
|
0494d0dc0e
|
||
|
|
c9beed8f0d
|
||
|
|
3a1b5e0f35
|
||
|
|
28dec3e4af
|
||
|
|
a8399284d6
|
||
|
|
e50989a3e4
|
||
|
|
b8f66626c2
|
||
|
|
39a7a8beda
|
||
|
|
6cc839fdd4
|
||
|
|
b9dacf4d5a
|
||
|
|
cbdef1ecf9
|
||
|
|
9f6e953495
|
||
|
|
8546d80f65
|
||
|
|
84a13ae3cc
|
||
|
|
2d028ca37e
|
||
|
|
7589d7c440
|
No files matched your search
@@ -1 +1,2 @@
|
|||||||
/.log/
|
/.log/
|
||||||
|
tmp/
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[defaults]
|
||||||
|
inventory = ./inventory.ini
|
||||||
|
roles_path = ./roles
|
||||||
@@ -6,8 +6,9 @@
|
|||||||
vars:
|
vars:
|
||||||
frp_version: "0.71.0"
|
frp_version: "0.71.0"
|
||||||
frp_download_url: "https://github.com/fatedier/frp/releases/download/v{{ frp_version }}/frp_{{ frp_version }}_linux_amd64.tar.gz"
|
frp_download_url: "https://github.com/fatedier/frp/releases/download/v{{ frp_version }}/frp_{{ frp_version }}_linux_amd64.tar.gz"
|
||||||
frp_local_archive: "/tmp/frp_{{ frp_version }}_linux_amd64.tar.gz"
|
frp_tmp_dir: "{{ playbook_dir }}/../tmp"
|
||||||
frp_local_tmp_dir: "/tmp/frp_{{ frp_version }}_linux_amd64"
|
frp_local_archive: "{{ frp_tmp_dir }}/frp_{{ frp_version }}_linux_amd64.tar.gz"
|
||||||
|
frp_local_tmp_dir: "{{ frp_tmp_dir }}/frp_{{ frp_version }}_linux_amd64"
|
||||||
frp_install_dir: "/opt/frp"
|
frp_install_dir: "/opt/frp"
|
||||||
frp_config_dir: "/etc/frp"
|
frp_config_dir: "/etc/frp"
|
||||||
vars_files:
|
vars_files:
|
||||||
@@ -43,7 +44,7 @@
|
|||||||
- name: 解压 frp 压缩包到本地
|
- name: 解压 frp 压缩包到本地
|
||||||
unarchive:
|
unarchive:
|
||||||
src: "{{ frp_local_archive }}"
|
src: "{{ frp_local_archive }}"
|
||||||
dest: "/tmp/"
|
dest: "{{ frp_tmp_dir }}"
|
||||||
creates: "{{ frp_local_tmp_dir }}"
|
creates: "{{ frp_local_tmp_dir }}"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|||||||
@@ -12,14 +12,10 @@
|
|||||||
timezone: Asia/Shanghai
|
timezone: Asia/Shanghai
|
||||||
ssh_public_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
ssh_public_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||||
|
|
||||||
tasks:
|
roles:
|
||||||
- name: 启用 BBR
|
- role: bbr
|
||||||
sysctl:
|
|
||||||
name: net.ipv4.tcp_congestion_control
|
|
||||||
value: bbr
|
|
||||||
sysctl_set: yes
|
|
||||||
reload: yes
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
- name: 设置时区
|
- name: 设置时区
|
||||||
timezone:
|
timezone:
|
||||||
name: "{{ timezone }}"
|
name: "{{ timezone }}"
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#+title: TCP 拥塞控制算法设置为 BBR
|
||||||
|
|
||||||
|
这个 role 是为了将服务器上的 linux 系统的 TCP 拥塞控制算法设置为 BBR 以提供更好的网络环境,
|
||||||
|
主要时提高吞吐量,降低延迟和提升弱网稳定性。
|
||||||
|
|
||||||
|
最开始是使用 =ansible= 的 =sysctl= 模块实现的,配置是写入 =/etc/sysctl.conf= 的,但后面发现重启机器后配置未生效。
|
||||||
|
|
||||||
|
查询原因发现是 =systemd-sysctl= 不会读取 =/etc/sysctl.conf= ,读取的是 =/etc/sysctl.d= 目录下的配置文件。
|
||||||
|
因此配置方式改为手动写入配置文件,不再直接使用 ansible 的 sysctl 模块。
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- name: reload sysctl
|
||||||
|
command: sysctl --system
|
||||||
|
changed_when: false
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
- name: 启用 BBR
|
||||||
|
copy:
|
||||||
|
dest: /etc/sysctl.d/bbr.conf
|
||||||
|
content: |
|
||||||
|
net.core.default_qdisc=fq
|
||||||
|
net.ipv4.tcp_congestion_control=bbr
|
||||||
|
mode: '0644'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
notify: reload sysctl
|
||||||
|
|
||||||
|
- name: 应用 sysctl 配置
|
||||||
|
command: sysctl --system
|
||||||
|
changed_when: false
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- import_tasks: config.yaml
|
||||||
|
- import_tasks: module.yaml
|
||||||
|
- import_tasks: verify.yaml
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
- name: 开机加载 tcp_bbr 模块
|
||||||
|
copy:
|
||||||
|
dest: /etc/modules-load.d/bbr.conf
|
||||||
|
content: "tcp_bbr\n"
|
||||||
|
mode: '0644'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: 立即加载 tcp_bbr 模块
|
||||||
|
modprobe:
|
||||||
|
name: tcp_bbr
|
||||||
|
state: present
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: 获取可用的 TCP 拥塞控制算法列表
|
||||||
|
command: sysctl net.ipv4.tcp_available_congestion_control
|
||||||
|
register: available_cc
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: 确认 bbr 在可用列表中
|
||||||
|
fail:
|
||||||
|
msg: "BBR 不在可用的 TCP 拥塞控制算法列表中"
|
||||||
|
when: "'bbr' not in available_cc.stdout"
|
||||||
|
|
||||||
|
- name: 验证当前拥塞控制算法
|
||||||
|
command: sysctl net.ipv4.tcp_congestion_control
|
||||||
|
register: current_cc
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: 打印当前 TCP 拥塞控制算法
|
||||||
|
debug:
|
||||||
|
msg: "当前 TPC 拥塞控制算法: {{ current_cc.stdout }}"
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
bindPort = {{ vault_frps_bind_port }}
|
bindPort = {{ vault_frps_bind_port }}
|
||||||
|
|
||||||
vhostHTTPPort = {{ vault_frps_vhost_http_port }}
|
vhostHTTPPort = {{ vault_frps_vhost_http_port }}
|
||||||
vhostHTTPSPort = {{ vault_frps_vhost_https_port }}
|
|
||||||
|
|
||||||
auth.method = "token"
|
auth.method = "token"
|
||||||
auth.token = "{{ vault_frps_token }}"
|
auth.token = "{{ vault_frps_token }}"
|
||||||
|
|
||||||
webServer.addr = "0.0.0.0"
|
webServer.addr = "127.0.0.1"
|
||||||
webServer.port = {{ vault_frps_dashboard_port }}
|
webServer.port = {{ vault_frps_dashboard_port }}
|
||||||
webServer.user = "{{ vault_frps_dashboard_user }}"
|
webServer.user = "{{ vault_frps_dashboard_user }}"
|
||||||
webServer.password = "{{ vault_frps_dashboard_password }}"
|
webServer.password = "{{ vault_frps_dashboard_password }}"
|
||||||
|
|||||||
Whitespace-only changes.
+33
-33
@@ -1,34 +1,34 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
31623833356637343262363863626534323535626238346439333262633332633136633261306466
|
31326665376531376630356363393661653431613931326234643966653463393735366564323734
|
||||||
6236333066363461326664306262633937323864306462370a333631643039653664643662366234
|
3730396363393537306239663835373062306633646264310a343665376130396339333637346439
|
||||||
30643231336631313930663637396537663162623938363263336333343262376561323765356630
|
38396237326237363265616437653564636436313732303365376630643033356166336236383831
|
||||||
6332383136383336640a336536316566393461666463616265363830383331363838613839636338
|
3837356238653537380a633130376466623963613361653738353665376239323864323430623063
|
||||||
63666365333233646533303166316333393535313466393832643966306331666434333065333238
|
39343862633838333834303936346365666236653731346532336132383461316162666666656565
|
||||||
37633735313832366131653833363762393265656439663135376265366466333838623761646535
|
65643731353635383037353132313534376466653031366133646332383830336662636263373566
|
||||||
64633236663738653233633566633734306138393462383532306436373537343332343565356466
|
65393466306639363439303165353032666635323131633536643862643533666463313839383361
|
||||||
62386664373631336138396134613833636232663936363963656638353133386430376631383438
|
33363434666532366666633935353466383134643731376236346661653765643830326537386630
|
||||||
35313866343438636564373566373239656233376432363362613466356334346339616562316530
|
31656437653935636130356566616436346564306364343538306138353364633135333565393462
|
||||||
62306361646362353631336134326136346663623061643231666433353265653736323162616166
|
37353037343861346438613430643561666462663831303332376238386135636538653431636466
|
||||||
32313132643832306563623861393735623439376432346136623732353737356338616432316161
|
39633033613166316465313462656262343032303430346133386663623930376237633065656263
|
||||||
64316436653531356362316366383039616465313233393663663566316532626138363936363736
|
35313263316466346437353237373538383632326534656365376630396136646530653165316637
|
||||||
31386237653634343236326639376531653465636233636662303037643930633661623338356537
|
61333262386361326562353136393433663633663362326564386238366333656330343561323730
|
||||||
34636639383662646234313037363230373333333731323666383232626330663561396330356361
|
36383761313864316135353332306134636661383430316538326436653436386430333762656134
|
||||||
36346537376431333235393938636664306532373863353862663166613862363165643433626361
|
33373234386365663836356430366633316262646538636237303636636635373335336534373630
|
||||||
37616337356538373733313130633334353436643437366534326636616539316166336137346461
|
38363131373666613430373031393036636632626338326436323635366462396639396661306439
|
||||||
63633130623436316463623461353762313533636262653262393930666434386664326464636562
|
35663138346163306561393262323366636264386130313165383836353936633634613930656133
|
||||||
35636233656365616332383565623230353062663236316437333830626463333366633230393432
|
39323330373232313265366565353061663665613365396166373734386432353931313638333466
|
||||||
33386533346436623132313036646536366339646333643732633133626631396463653533363763
|
65333732333133613866313363356133353965323966373132326535383464303262353665636537
|
||||||
37623439303931363933336432386430336662353138663231316436356535373831653232633562
|
34333237353365303136366338613664363936613063636663303861383161616337613532363162
|
||||||
33626463303134323032643535373038303530376632393162356630613134396261633661393335
|
63353066646563353964623734636236613530636564393537633461336263303565376337653435
|
||||||
30646133366166313533666565326335656231663864666333366136616264356535303033313832
|
38626230666430383533646561396232356665623962663334393461633365633839323866343031
|
||||||
35323432613063356161383365653964613339346136333363363763316463396364383264343634
|
30333239666437626439373236663535373664326337333864656237333963616139653031313430
|
||||||
65623039343064356430386662323135303134306539313138316633396635333331636137356665
|
34306336663533313536383435626161336130623333303034666235393266343935363466313431
|
||||||
38623531613138316162353733663631396562313033393066303266396533613762643936663936
|
36653566396535656434346132313165626264313236363734306531316438656666333532343638
|
||||||
65663762646264616439666138636364343264323961343739336330663237666661303639363835
|
30613432343834373166313063663333663930386636306165346536636336393438323464396635
|
||||||
63636562636336613665366533333563323239633338663738363931383333356264313166393132
|
34393263633266356635623834306239663634323430313765323635626666633337663936636465
|
||||||
30643636303333616161346166323933623432613633643965313366643565343931633338303237
|
34316637623736353239343430383366343063656430346230393538653834633364343830336435
|
||||||
35636365333262386135623866343839313836616664663764323938636630393062383462343437
|
37313461626334346130343766363364643636643865383931376635333532363165343932616632
|
||||||
32636664663635643934396166373462303638343437623961373362366230633466363936326162
|
39663665383833646131326534643737323364343033633135383333643136616532323931333439
|
||||||
38303130346439323863643836666565326530363362306432623036303562636532333966386463
|
61326338636637353266383463383365383364663330653565386566353434303232643738343037
|
||||||
31353063363839633736366133353535643064363461653030346432393461623666616666643231
|
62613065333961383136656236636234623338343466333232363861323034633738343035633535
|
||||||
63333831653963356632316333396130653934653134623339323438653638643031
|
3733
|
||||||
+5
-4
@@ -5,12 +5,13 @@
|
|||||||
* 文件用途
|
* 文件用途
|
||||||
|
|
||||||
| 文件 | 说明 |
|
| 文件 | 说明 |
|
||||||
|----------------------+--------------------------------|
|
|----------------------+---------------------------|
|
||||||
| y480.yaml | 家用服务器 docker compose 配置 |
|
| v2raya.yaml | V2rayA 代理客户端容器配置 |
|
||||||
| xray-config.json | xray 服务器配置 |
|
|
||||||
| V2RayA-RoutingA.conf | V2rayA 路由配置 |
|
| V2RayA-RoutingA.conf | V2rayA 路由配置 |
|
||||||
|
| webdav.yaml | webdav 服务容器配置 |
|
||||||
|
| webdav-config.yaml | webdav 配置文件 |
|
||||||
|
|
||||||
* docker 镜像对应的 git 仓库
|
* docker 镜像对应的 git 仓库
|
||||||
|
|
||||||
- https://github.com/ronggang/OWSS
|
- https://github.com/hacdias/webdav
|
||||||
- https://github.com/v2rayA/v2rayA
|
- https://github.com/v2rayA/v2rayA
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
proxy_ip="192.168.0.104"
|
proxy_ip="127.0.0.1"
|
||||||
proxy_http_port="20172"
|
proxy_http_port="20172"
|
||||||
# SOCKS_PROXY="socks5://${PROXY_IP}:20170"
|
# SOCKS_PROXY="socks5://${PROXY_IP}:20170"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* -*- mode: js; -*- */
|
/* -*- mode: js; -*- */
|
||||||
const proxy_ip = "192.168.0.104"
|
const proxy_ip = "127.0.0.1"
|
||||||
const PROXY = `SOCKS5 ${proxy_ip}:20170; HTTP ${proxy_ip}:20172; DIRECT`;
|
const PROXY = `SOCKS5 ${proxy_ip}:20170; HTTP ${proxy_ip}:20172; DIRECT`;
|
||||||
const DIRECT = 'DIRECT';
|
const DIRECT = 'DIRECT';
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ const direct_ip_list = [
|
|||||||
["192.168.0.0", "255.255.255.0"],
|
["192.168.0.0", "255.255.255.0"],
|
||||||
["192.168.1.0", "255.255.255.0"],
|
["192.168.1.0", "255.255.255.0"],
|
||||||
["192.168.2.0", "255.255.255.0"],
|
["192.168.2.0", "255.255.255.0"],
|
||||||
|
["192.168.5.0", "255.255.255.0"],
|
||||||
["127.0.0.1", "255.255.255.0"],
|
["127.0.0.1", "255.255.255.0"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,12 @@ QUICKPKG_DEFAULT_OPTS="--include-config y"
|
|||||||
BINPKG_FORMAT="gpkg"
|
BINPKG_FORMAT="gpkg"
|
||||||
EMERGE_DEFAULT_OPTS="--buildpkg --buildpkg-exclude \"virtual/* sys-kernel/*-sources */*-bin\" ${EMERGE_DEFAULT_OPTS}"
|
EMERGE_DEFAULT_OPTS="--buildpkg --buildpkg-exclude \"virtual/* sys-kernel/*-sources */*-bin\" ${EMERGE_DEFAULT_OPTS}"
|
||||||
|
|
||||||
# ccache and distcc
|
# distcc
|
||||||
FEATURES="distcc ccache ${FEATURES}"
|
FEATURES="distcc ${FEATURES}"
|
||||||
|
DISTCC_DIR="/var/tmp/distcc"
|
||||||
|
|
||||||
|
# ccache
|
||||||
|
FEATURES="ccache ${FEATURES}"
|
||||||
CCACHE_DIR="/var/cache/ccache"
|
CCACHE_DIR="/var/cache/ccache"
|
||||||
CCACHE_UMASK="0002"
|
CCACHE_UMASK="0002"
|
||||||
|
|
||||||
@@ -29,13 +33,12 @@ CCACHE_UMASK="0002"
|
|||||||
ALSA_CARDS="hda-intel"
|
ALSA_CARDS="hda-intel"
|
||||||
GRUB_PLATFORMS="efi-64"
|
GRUB_PLATFORMS="efi-64"
|
||||||
INPUT_DEVICES="libinput"
|
INPUT_DEVICES="libinput"
|
||||||
VIDEO_CARDS="amdgpu dummy fbdev intel nouveau nvidia radeon radeonsi vesa"
|
VIDEO_CARDS="amdgpu dummy fbdev intel nouveau radeon radeonsi vesa"
|
||||||
|
|
||||||
GENTOO_MIRRORS="
|
GENTOO_MIRRORS="
|
||||||
http://distfiles.gentoo.org/
|
http://distfiles.gentoo.org/
|
||||||
"
|
"
|
||||||
MAKEOPTS="-j9 ${MAKEOPTS}"
|
|
||||||
|
|
||||||
DESKTOP_USE="X alsa apng dbus fbcon ffmpeg flac fuse gif gtk gtk2 gtk3 http2 icu jack jpeg mp3 mp4 mpeg mtp nvidia ogg opengl pdf png pipewire pulseaudio svg tiff unicode vaapi vdpau webp xinerama xv xvmc"
|
DESKTOP_USE="X alsa apng dbus fbcon ffmpeg flac fuse gif gtk gtk2 gtk3 http2 icu jack jpeg mp3 mp4 mpeg mtp nvidia ogg opengl pdf png pipewire pulseaudio svg tiff unicode vaapi vdpau vulkan webp xinerama xv xvmc"
|
||||||
#USE="${USE} ${DESKTOP_USE} consolekit cups policykit pulseaudio truetype udev xft xcb xkb -bluetooth -gpm -libva -modemmanager"
|
#USE="${USE} ${DESKTOP_USE} consolekit cups policykit pulseaudio truetype udev xft xcb xkb -bluetooth -gpm -libva -modemmanager"
|
||||||
USE="${USE} ${DESKTOP_USE} bluetooth cups elogind policykit truetype udev xft xcb xkb -gpm -libva -modemmanager"
|
USE="${USE} ${DESKTOP_USE} bluetooth cups elogind policykit truetype udev xft xcb xkb -gpm -libva -modemmanager"
|
||||||
@@ -20,8 +20,8 @@ dev-util/android-studio ~amd64
|
|||||||
net-vpn/frp ~amd64
|
net-vpn/frp ~amd64
|
||||||
|
|
||||||
# firefox
|
# firefox
|
||||||
dev-libs/nspr ~amd64
|
# dev-libs/nspr ~amd64
|
||||||
dev-libs/nss ~amd64
|
# dev-libs/nss ~amd64
|
||||||
www-client/firefox ~amd64
|
www-client/firefox ~amd64
|
||||||
|
|
||||||
# wechat
|
# wechat
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ media-tv/plex-media-server Plex
|
|||||||
net-analyzer/nmap NPSL
|
net-analyzer/nmap NPSL
|
||||||
net-im/deepin-wine-wechat Tencent
|
net-im/deepin-wine-wechat Tencent
|
||||||
net-im/dingtalk all-rights-reserved
|
net-im/dingtalk all-rights-reserved
|
||||||
net-im/wechat all-rights-reserved
|
net-im/wechat Tencent-Weixin
|
||||||
net-im/wechat-universal-bwrap all-rights-reserved
|
net-im/wechat-universal-bwrap all-rights-reserved
|
||||||
net-im/wemeet wemeet_license
|
net-im/wemeet wemeet_license
|
||||||
net-misc/anydesk AnyDesk-TOS
|
net-misc/anydesk AnyDesk-TOS
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ sys-libs/zlib minizip
|
|||||||
sys-devel/gcc lto pgo
|
sys-devel/gcc lto pgo
|
||||||
|
|
||||||
# kernel
|
# kernel
|
||||||
sys-kernel/installkernel grub
|
sys-kernel/installkernel dracut grub
|
||||||
|
|
||||||
# terminal
|
# terminal
|
||||||
x11-terms/xterm sixel xinerama
|
x11-terms/xterm sixel xinerama
|
||||||
@@ -71,7 +71,7 @@ net-fs/samba client
|
|||||||
net-libs/ngtcp2 gnutls
|
net-libs/ngtcp2 gnutls
|
||||||
|
|
||||||
# mpv
|
# mpv
|
||||||
media-video/mpv bluray dvd nvenc pipewire -vulkan
|
media-video/mpv bluray dvd nvenc pipewire
|
||||||
|
|
||||||
# pdf-tools need poppler-glib library
|
# pdf-tools need poppler-glib library
|
||||||
app-text/poppler cairo
|
app-text/poppler cairo
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
From 5887505185b9129a2de6c4b36f1dbac5fe4e6358 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Norayr Chilingarian <norayr@arnet.am>
|
||||||
|
Date: Sun, 18 May 2025 13:39:02 +0400
|
||||||
|
Subject: [PATCH] Fix build with GCC 14 and modern glib: const correctness and
|
||||||
|
deprecated API
|
||||||
|
|
||||||
|
- Use 'const gchar*' for result of g_utf8_next_char() to satisfy GCC 14's stricter const rules
|
||||||
|
- Remove incorrect g_free() on non-allocated pointer from g_utf8_next_char()
|
||||||
|
- Replace deprecated g_pattern_match_string() with g_pattern_spec_match_string()
|
||||||
|
---
|
||||||
|
src/stardict_lib.cpp | 5 ++---
|
||||||
|
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp
|
||||||
|
index 83fbc59..13cf779 100644
|
||||||
|
--- a/src/stardict_lib.cpp
|
||||||
|
+++ b/src/stardict_lib.cpp
|
||||||
|
@@ -989,7 +989,7 @@ bool Dict::LookupWithRule(GPatternSpec *pspec, glong *aIndex, int iBuffLen)
|
||||||
|
int iIndexCount = 0;
|
||||||
|
|
||||||
|
for (guint32 i = 0; i < narticles() && iIndexCount < (iBuffLen - 1); i++)
|
||||||
|
- if (g_pattern_match_string(pspec, get_key(i)))
|
||||||
|
+ if (g_pattern_spec_match_string(pspec, get_key(i)))
|
||||||
|
aIndex[iIndexCount++] = i;
|
||||||
|
|
||||||
|
aIndex[iIndexCount] = -1; // -1 is the end.
|
||||||
|
@@ -1047,12 +1047,11 @@ bool Libs::LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices,
|
||||||
|
}
|
||||||
|
// Upper the first character and lower others.
|
||||||
|
if (!bFound) {
|
||||||
|
- gchar *nextchar = g_utf8_next_char(sWord);
|
||||||
|
+ const gchar *nextchar = g_utf8_next_char(sWord);
|
||||||
|
gchar *firstchar = g_utf8_strup(sWord, nextchar - sWord);
|
||||||
|
nextchar = g_utf8_strdown(nextchar, -1);
|
||||||
|
casestr = g_strdup_printf("%s%s", firstchar, nextchar);
|
||||||
|
g_free(firstchar);
|
||||||
|
- g_free(nextchar);
|
||||||
|
if (strcmp(casestr, sWord)) {
|
||||||
|
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||||
|
bFound = true;
|
||||||
|
--
|
||||||
|
2.55.0
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
From 849f0ed1ac24b21530b2085ae17b85a98fa04a59 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Evgeniy A. Dushistov" <dushistov@mail.ru>
|
||||||
|
Date: Sun, 17 Aug 2025 13:43:07 +0300
|
||||||
|
Subject: [PATCH] fix: memory leak instroduced in #110
|
||||||
|
|
||||||
|
---
|
||||||
|
src/stardict_lib.cpp | 9 +++++----
|
||||||
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/stardict_lib.cpp b/src/stardict_lib.cpp
|
||||||
|
index 13cf779..6b0d55c 100644
|
||||||
|
--- a/src/stardict_lib.cpp
|
||||||
|
+++ b/src/stardict_lib.cpp
|
||||||
|
@@ -1047,10 +1047,11 @@ bool Libs::LookupSimilarWord(const gchar *sWord, std::set<glong> &iWordIndices,
|
||||||
|
}
|
||||||
|
// Upper the first character and lower others.
|
||||||
|
if (!bFound) {
|
||||||
|
- const gchar *nextchar = g_utf8_next_char(sWord);
|
||||||
|
- gchar *firstchar = g_utf8_strup(sWord, nextchar - sWord);
|
||||||
|
- nextchar = g_utf8_strdown(nextchar, -1);
|
||||||
|
- casestr = g_strdup_printf("%s%s", firstchar, nextchar);
|
||||||
|
+ const gchar *rest = g_utf8_next_char(sWord);
|
||||||
|
+ gchar *firstchar = g_utf8_strup(sWord, rest - sWord);
|
||||||
|
+ gchar *rest_lowercase = g_utf8_strdown(rest, -1);
|
||||||
|
+ casestr = g_strdup_printf("%s%s", firstchar, rest_lowercase);
|
||||||
|
+ g_free(rest_lowercase);
|
||||||
|
g_free(firstchar);
|
||||||
|
if (strcmp(casestr, sWord)) {
|
||||||
|
if (oLib[iLib]->Lookup(casestr, iWordIndices))
|
||||||
|
--
|
||||||
|
2.55.0
|
||||||
|
|
||||||
Reference in new issue
Block a user