mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Merge remote branch 'origin/master' into lua-config
Conflicts: src/CMakeLists.txt
This commit is contained in:
commit
8c6c0aa995
@ -1,3 +1,6 @@
|
||||
2010-02-18
|
||||
* $memwithbuffers object and bar (sf.net #2954143), thanks kingfishr
|
||||
|
||||
2009-12-09
|
||||
* Replaced GHashTable with tr1::unordered_map in tcp_portmon.
|
||||
This means portmon no longer depends on glib.
|
||||
|
@ -87,6 +87,11 @@ option(BUILD_BUILTIN_CONFIG "Enable builtin default configuration" true)
|
||||
option(BUILD_MATH "Enable math support" true)
|
||||
|
||||
option(BUILD_NCURSES "Enable ncurses support" true)
|
||||
if(BUILD_NCURSES)
|
||||
option(LEAKFREE_NCURSES "Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)" false)
|
||||
else(BUILD_NCURSES)
|
||||
set(LEAKFREE_NCURSES false CACHE BOOL "Enable to hide false ncurses-memleaks in valgrind (works only when ncurses is compiled with --disable-leaks)" FORCE)
|
||||
endif(BUILD_NCURSES)
|
||||
|
||||
option(BUILD_X11 "Build X11 support" true)
|
||||
if(BUILD_X11)
|
||||
|
@ -89,7 +89,7 @@ if(BUILD_WLAN)
|
||||
if(NOT IWLIB_LIB)
|
||||
message(FATAL_ERROR "Unable to find libiw.so")
|
||||
endif(NOT IWLIB_LIB)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${IWLIB_LIB})
|
||||
set(conky_libs ${conky_libs} ${IWLIB_LIB})
|
||||
check_function_exists(iw_sockets_open IWLIB_SOCKETS_OPEN_FUNC)
|
||||
endif(BUILD_WLAN)
|
||||
|
||||
|
@ -78,6 +78,7 @@
|
||||
#cmakedefine BUILD_BUILTIN_CONFIG 1
|
||||
|
||||
#cmakedefine BUILD_NCURSES 1
|
||||
#cmakedefine LEAKFREE_NCURSES 1
|
||||
|
||||
#cmakedefine BUILD_APCUPSD 1
|
||||
|
||||
|
@ -106,6 +106,19 @@
|
||||
<listitem>Create own window to draw
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>-s | --for-scripts</option>
|
||||
</command>
|
||||
<option>TEXT</option>
|
||||
</term>
|
||||
<listitem>Prints TEXT on the standard output and exits.
|
||||
(This option makes conky useful in scripts)
|
||||
TEXT has to be enclosed by single quotes. Example:
|
||||
conky -s 'Your uptime is: $uptime'
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
|
@ -1971,6 +1971,15 @@
|
||||
<listitem>Amount of memory in use
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>memwithbuffers</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>Amount of memory in use, including that used by system buffers and caches
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
@ -1981,6 +1990,16 @@
|
||||
<listitem>Bar that shows amount of memory in use
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>memwithbuffersbar</option>
|
||||
</command>
|
||||
<option>(height),(width)</option>
|
||||
</term>
|
||||
<listitem>Bar that shows amount of memory in use (including memory used by system buffers and caches)
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
|
@ -11,7 +11,7 @@ color green "\<(alignment|append_file|background|border_inner_margin|border_oute
|
||||
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>"
|
||||
|
||||
## Variables
|
||||
color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|format_time|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|include|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|membar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|nameserver|new_mails|nodename|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_nice|pid_openfiles|pid_parent|pid_priority|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_threads|pid_thread_list|pid_time_kernelmode|pid_time_usermode|pid_time|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_read|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|pid_write|platform|pop3_unseen|pop3_used|pre_exec|processes|read_tcp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>"
|
||||
color brightblue "\<(acpiacadapter|acpifan|acpitemp|addr|addrs|alignc|alignr|apcupsd|apcupsd_cable|apcupsd_charge|apcupsd_lastxfer|apcupsd_linev|apcupsd_load|apcupsd_loadbar|apcupsd_loadgauge|apcupsd_loadgraph|apcupsd_model|apcupsd_name|apcupsd_status|apcupsd_temp|apcupsd_timeleft|apcupsd_upsmode|apm_adapter|apm_battery_life|apm_battery_time|audacious_bar|audacious_bitrate|audacious_channels|audacious_filename|audacious_frequency|audacious_length|audacious_length_seconds|audacious_main_volume|audacious_playlist_length|audacious_playlist_position|audacious_position|audacious_position_seconds|audacious_status|audacious_title|battery|battery_bar|battery_percent|battery_short|battery_time|blink|bmpx_album|bmpx_artist|bmpx_bitrate|bmpx_title|bmpx_track|bmpx_uri|buffers|cached|cmdline_to_pid|color|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|combine|conky_build_arch|conky_build_date|conky_version|cpu|cpubar|cpugauge|cpugraph|curl|desktop|desktop_name|desktop_number|disk_protect|diskio|diskio_read|diskio_write|diskiograph|diskiograph_read|diskiograph_write|downspeed|downspeedf|downspeedgraph|draft_mails|else|endif|entropy_avail|entropy_bar|entropy_perc|entropy_poolsize|eval|eve|exec|execbar|execgauge|execgraph|execi|execibar|execigauge|execigraph|execp|execpi|flagged_mails|font|format_time|forwarded_mails|freq|freq_g|fs_bar|fs_bar_free|fs_free|fs_free_perc|fs_size|fs_type|fs_used|fs_used_perc|goto|gw_iface|gw_ip|hddtemp|head|hr|hwmon|i2c|i8k_ac_status|i8k_bios|i8k_buttons_status|i8k_cpu_temp|i8k_left_fan_rpm|i8k_left_fan_status|i8k_right_fan_rpm|i8k_right_fan_status|i8k_serial|i8k_version|ibm_brightness|ibm_fan|ibm_temps|ibm_volume|iconv_start|iconv_stop|if_empty|if_existing|if_gw|if_match|if_mixer_mute|if_mounted|if_mpd_playing|if_running|if_smapi_bat_installed|if_up|if_updatenr|if_xmms2_connected|image|imap_messages|imap_unseen|include|ioscheduler|kernel|laptop_mode|lines|loadavg|loadgraph|lua|lua_bar|lua_gauge|lua_graph|lua_parse|machine|mails|mboxscan|mem|memwithbuffers|membar|memwithbuffersbar|memeasyfree|memfree|memgauge|memgraph|memmax|memperc|mixer|mixerbar|mixerl|mixerlbar|mixerr|mixerrbar|moc_album|moc_artist|moc_bitrate|moc_curtime|moc_file|moc_rate|moc_song|moc_state|moc_timeleft|moc_title|moc_totaltime|monitor|monitor_number|mpd_album|mpd_artist|mpd_bar|mpd_bitrate|mpd_elapsed|mpd_file|mpd_length|mpd_name|mpd_percent|mpd_random|mpd_repeat|mpd_smart|mpd_status|mpd_title|mpd_track|mpd_vol|nameserver|new_mails|nodename|nvidia|obsd_product|obsd_sensors_fan|obsd_sensors_temp|obsd_sensors_volt|obsd_vendor|offset|outlinecolor|pb_battery|pid_chroot|pid_cmdline|pid_cwd|pid_environ|pid_environ_list|pid_exe|pid_nice|pid_openfiles|pid_parent|pid_priority|pid_state|pid_state_short|pid_stderr|pid_stdin|pid_stdout|pid_threads|pid_thread_list|pid_time_kernelmode|pid_time_usermode|pid_time|pid_uid|pid_euid|pid_suid|pid_fsuid|pid_gid|pid_egid|pid_sgid|pid_fsgid|pid_read|pid_vmpeak|pid_vmsize|pid_vmlck|pid_vmhwm|pid_vmrss|pid_vmdata|pid_vmstk|pid_vmexe|pid_vmlib|pid_vmpte|pid_write|platform|pop3_unseen|pop3_used|pre_exec|processes|read_tcp|replied_mails|rss|running_processes|running_threads|scroll|seen_mails|shadecolor|smapi|smapi_bat_bar|smapi_bat_perc|smapi_bat_power|smapi_bat_temp|sony_fanspeed|stippled_hr|swap|swapbar|swapfree|swapmax|swapperc|sysname|tab|tail|tcp_portmon|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|texeci|texecpi|threads|time|to_bytes|top|top_io|top_mem|top_time|totaldown|totalup|trashed_mails|tztime|gid_name|uid_name|unflagged_mails|unforwarded_mails|unreplied_mails|unseen_mails|updates|upspeed|upspeedf|upspeedgraph|uptime|uptime_short|user_names|user_number|user_terms|user_times|user_time|utime|voffset|voltage_mv|voltage_v|weather|wireless_ap|wireless_bitrate|wireless_essid|wireless_link_bar|wireless_link_qual|wireless_link_qual_max|wireless_link_qual_perc|wireless_mode|words|xmms2_album|xmms2_artist|xmms2_bar|xmms2_bitrate|xmms2_comment|xmms2_date|xmms2_duration|xmms2_elapsed|xmms2_genre|xmms2_id|xmms2_percent|xmms2_playlist|xmms2_size|xmms2_smart|xmms2_status|xmms2_timesplayed|xmms2_title|xmms2_tracknr|xmms2_url)\>"
|
||||
|
||||
color brightblue "\$\{?[0-9A-Z_!@#$*?-]+\}?"
|
||||
color cyan "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
|
||||
|
@ -50,7 +50,7 @@ syn region ConkyrcVar start=/\$\w\@=/ end=/\W\@=\|$/ contained contains=ConkyrcV
|
||||
|
||||
syn match ConkyrcVarStuff /{\@<=/ms=s contained nextgroup=ConkyrcVarName
|
||||
|
||||
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font format_time forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen include ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem membar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol nameserver new_mails nodename nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_nice pid_openfiles pid_parent pid_priority pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_threads pid_thread_list pid_time_kernelmode pid_time_usermode pid_time pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_read pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte pid_write platform pop3_unseen pop3_used pre_exec processes read_tcp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapfree swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url
|
||||
syn keyword ConkyrcVarName contained nextgroup=ConkyrcNumber,ConkyrcColour skipwhite acpiacadapter acpifan acpitemp addr addrs alignc alignr apcupsd apcupsd_cable apcupsd_charge apcupsd_lastxfer apcupsd_linev apcupsd_load apcupsd_loadbar apcupsd_loadgauge apcupsd_loadgraph apcupsd_model apcupsd_name apcupsd_status apcupsd_temp apcupsd_timeleft apcupsd_upsmode apm_adapter apm_battery_life apm_battery_time audacious_bar audacious_bitrate audacious_channels audacious_filename audacious_frequency audacious_length audacious_length_seconds audacious_main_volume audacious_playlist_length audacious_playlist_position audacious_position audacious_position_seconds audacious_status audacious_title battery battery_bar battery_percent battery_short battery_time blink bmpx_album bmpx_artist bmpx_bitrate bmpx_title bmpx_track bmpx_uri buffers cached cmdline_to_pid color color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 combine conky_build_arch conky_build_date conky_version cpu cpubar cpugauge cpugraph curl desktop desktop_name desktop_number disk_protect diskio diskio_read diskio_write diskiograph diskiograph_read diskiograph_write downspeed downspeedf downspeedgraph draft_mails else endif entropy_avail entropy_bar entropy_perc entropy_poolsize eval eve exec execbar execgauge execgraph execi execibar execigauge execigraph execp execpi flagged_mails font format_time forwarded_mails freq freq_g fs_bar fs_bar_free fs_free fs_free_perc fs_size fs_type fs_used fs_used_perc goto gw_iface gw_ip hddtemp head hr hwmon i2c i8k_ac_status i8k_bios i8k_buttons_status i8k_cpu_temp i8k_left_fan_rpm i8k_left_fan_status i8k_right_fan_rpm i8k_right_fan_status i8k_serial i8k_version ibm_brightness ibm_fan ibm_temps ibm_volume iconv_start iconv_stop if_empty if_existing if_gw if_match if_mixer_mute if_mounted if_mpd_playing if_running if_smapi_bat_installed if_up if_updatenr if_xmms2_connected image imap_messages imap_unseen include ioscheduler kernel laptop_mode lines loadavg loadgraph lua lua_bar lua_gauge lua_graph lua_parse machine mails mboxscan mem memwithbuffers membar memwithbuffersbar memeasyfree memfree memgauge memgraph memmax memperc mixer mixerbar mixerl mixerlbar mixerr mixerrbar moc_album moc_artist moc_bitrate moc_curtime moc_file moc_rate moc_song moc_state moc_timeleft moc_title moc_totaltime monitor monitor_number mpd_album mpd_artist mpd_bar mpd_bitrate mpd_elapsed mpd_file mpd_length mpd_name mpd_percent mpd_random mpd_repeat mpd_smart mpd_status mpd_title mpd_track mpd_vol nameserver new_mails nodename nvidia obsd_product obsd_sensors_fan obsd_sensors_temp obsd_sensors_volt obsd_vendor offset outlinecolor pb_battery pid_chroot pid_cmdline pid_cwd pid_environ pid_environ_list pid_exe pid_nice pid_openfiles pid_parent pid_priority pid_state pid_state_short pid_stderr pid_stdin pid_stdout pid_threads pid_thread_list pid_time_kernelmode pid_time_usermode pid_time pid_uid pid_euid pid_suid pid_fsuid pid_gid pid_egid pid_sgid pid_fsgid pid_read pid_vmpeak pid_vmsize pid_vmlck pid_vmhwm pid_vmrss pid_vmdata pid_vmstk pid_vmexe pid_vmlib pid_vmpte pid_write platform pop3_unseen pop3_used pre_exec processes read_tcp replied_mails rss running_processes running_threads scroll seen_mails shadecolor smapi smapi_bat_bar smapi_bat_perc smapi_bat_power smapi_bat_temp sony_fanspeed stippled_hr swap swapbar swapfree swapmax swapperc sysname tab tail tcp_portmon template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 texeci texecpi threads time to_bytes top top_io top_mem top_time totaldown totalup trashed_mails tztime gid_name uid_name unflagged_mails unforwarded_mails unreplied_mails unseen_mails updates upspeed upspeedf upspeedgraph uptime uptime_short user_names user_number user_terms user_times user_time utime voffset voltage_mv voltage_v weather wireless_ap wireless_bitrate wireless_essid wireless_link_bar wireless_link_qual wireless_link_qual_max wireless_link_qual_perc wireless_mode words xmms2_album xmms2_artist xmms2_bar xmms2_bitrate xmms2_comment xmms2_date xmms2_duration xmms2_elapsed xmms2_genre xmms2_id xmms2_percent xmms2_playlist xmms2_size xmms2_smart xmms2_status xmms2_timesplayed xmms2_title xmms2_tracknr xmms2_url
|
||||
|
||||
hi def link ConkyrcComment Comment
|
||||
hi def link ConkyrcSetting Keyword
|
||||
|
@ -37,7 +37,7 @@ endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build.h)
|
||||
set(conky_sources colours.cc combine.cc common.cc conky.cc core.cc
|
||||
diskio.cc entropy.cc exec.cc fs.cc mail.cc mixer.cc net_stat.cc template.cc
|
||||
mboxscan.cc read_tcp.cc scroll.cc specials.cc tailhead.cc
|
||||
temphelper.cc text_object.cc timeinfo.cc top.cc algebra.cc prioqueue.c proc.cc
|
||||
temphelper.cc text_object.cc timeinfo.cc top.cc algebra.cc prioqueue.cc proc.cc
|
||||
user.cc luamm.cc data-source.cc lua-config.cc setting.cc)
|
||||
|
||||
# add timed thread library
|
||||
@ -166,7 +166,7 @@ if(BUILD_ICONV)
|
||||
endif(BUILD_ICONV)
|
||||
|
||||
if(BUILD_BUILTIN_CONFIG)
|
||||
set(optional_sources ${optional_sources} conf_cookie.c)
|
||||
set(optional_sources ${optional_sources} conf_cookie.cc)
|
||||
endif(BUILD_BUILTIN_CONFIG)
|
||||
|
||||
add_executable(conky ${conky_sources} ${optional_sources})
|
||||
|
15
src/bmpx.cc
15
src/bmpx.cc
@ -86,18 +86,9 @@ void update_bmpx()
|
||||
G_TYPE_INT, current_track, G_TYPE_INVALID,
|
||||
DBUS_TYPE_G_STRING_VALUE_HASHTABLE, &metadata,
|
||||
G_TYPE_INVALID)) {
|
||||
if (current_info->bmpx.title) {
|
||||
free(current_info->bmpx.title);
|
||||
current_info->bmpx.title = 0;
|
||||
}
|
||||
if (current_info->bmpx.artist) {
|
||||
free(current_info->bmpx.artist);
|
||||
current_info->bmpx.artist = 0;
|
||||
}
|
||||
if (current_info->bmpx.album) {
|
||||
free(current_info->bmpx.album);
|
||||
current_info->bmpx.album = 0;
|
||||
}
|
||||
free_and_zero(current_info->bmpx.title);
|
||||
free_and_zero(current_info->bmpx.artist);
|
||||
free_and_zero(current_info->bmpx.album);
|
||||
current_info->bmpx.title =
|
||||
g_value_dup_string(g_hash_table_lookup(metadata, "title"));
|
||||
current_info->bmpx.artist =
|
||||
|
@ -70,8 +70,8 @@ void ccurl_free_locations(ccurl_location_list &locations)
|
||||
{
|
||||
for (ccurl_location_list::iterator i = locations.begin();
|
||||
i != locations.end(); i++) {
|
||||
if ((*i)->uri) free((*i)->uri);
|
||||
if ((*i)->result) free((*i)->result);
|
||||
free_and_zero((*i)->uri);
|
||||
free_and_zero((*i)->result);
|
||||
}
|
||||
locations.clear();
|
||||
}
|
||||
@ -239,8 +239,5 @@ void curl_print(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void curl_obj_free(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
@ -124,7 +124,8 @@ void print_combine(struct text_object *obj, char *p, int p_max_size)
|
||||
generate_text_internal(&(buf[i][0]), max_user_text, *objsub);
|
||||
for(j=0; buf[i][j] != 0; j++) {
|
||||
if(buf[i][j] == '\t') buf[i][j] = ' ';
|
||||
if(buf[i][j] == '\n') {
|
||||
if(buf[i][j] == '\n') buf[i][j] = 0; //the vars inside combine may not have a \n at the end
|
||||
if(buf[i][j] == 2) { // \002 is used instead of \n to separate lines inside a var
|
||||
buf[i][j] = 0;
|
||||
current[i]->row = strdup(&(buf[i][0])+nextstart);
|
||||
if(i==0 && (long)strlen(current[i]->row) > longest) longest = (long)strlen(current[i]->row);
|
||||
@ -180,8 +181,9 @@ void free_combine(struct text_object *obj)
|
||||
free(cd->left);
|
||||
free(cd->seperation);
|
||||
free(cd->right);
|
||||
free_text_objects(obj->sub->sub);
|
||||
free_and_zero(obj->sub->sub);
|
||||
free_text_objects(obj->sub);
|
||||
free(obj->sub);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(obj->sub);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
@ -474,8 +474,7 @@ void scan_loadgraph_arg(struct text_object *obj, const char *arg)
|
||||
char *buf = 0;
|
||||
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
if (buf)
|
||||
free(buf);
|
||||
free_and_zero(buf);
|
||||
}
|
||||
|
||||
double loadgraphval(struct text_object *obj)
|
||||
@ -517,6 +516,7 @@ void print_##name(struct text_object *obj, char *p, int p_max_size) \
|
||||
}
|
||||
|
||||
PRINT_HR_GENERATOR(mem)
|
||||
PRINT_HR_GENERATOR(memwithbuffers)
|
||||
PRINT_HR_GENERATOR(memeasyfree)
|
||||
PRINT_HR_GENERATOR(memfree)
|
||||
PRINT_HR_GENERATOR(memmax)
|
||||
@ -538,6 +538,13 @@ double mem_barval(struct text_object *obj)
|
||||
return info.memmax ? ((double)info.mem / info.memmax) : 0;
|
||||
}
|
||||
|
||||
double mem_with_buffers_barval(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
|
||||
return info.memmax ? ((double)info.memwithbuffers / info.memmax) : 0;
|
||||
}
|
||||
|
||||
uint8_t swap_percentage(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
|
@ -105,6 +105,7 @@ uint8_t cpu_percentage(struct text_object *);
|
||||
double cpu_barval(struct text_object *);
|
||||
|
||||
void print_mem(struct text_object *, char *, int);
|
||||
void print_memwithbuffers(struct text_object *, char *, int);
|
||||
void print_memeasyfree(struct text_object *, char *, int);
|
||||
void print_memfree(struct text_object *, char *, int);
|
||||
void print_memmax(struct text_object *, char *, int);
|
||||
@ -113,6 +114,7 @@ void print_swapfree(struct text_object *, char *, int);
|
||||
void print_swapmax(struct text_object *, char *, int);
|
||||
uint8_t mem_percentage(struct text_object *);
|
||||
double mem_barval(struct text_object *);
|
||||
double mem_with_buffers_barval(struct text_object *);
|
||||
uint8_t swap_percentage(struct text_object *);
|
||||
double swap_barval(struct text_object *);
|
||||
|
||||
|
@ -61,14 +61,13 @@ conf_read(void *cookie, char *buf, COOKIE_LEN_T size)
|
||||
#endif /* defined(HAVE_FOPENCOOKIE) || defined(HAVE_FUNOPEN) */
|
||||
|
||||
#if defined(HAVE_FOPENCOOKIE)
|
||||
static cookie_io_functions_t conf_cookie = {
|
||||
.read = &conf_read,
|
||||
.write = NULL,
|
||||
.seek = NULL,
|
||||
.close = NULL,
|
||||
};
|
||||
static cookie_io_functions_t conf_cookie;
|
||||
FILE *conf_cookie_open(void)
|
||||
{
|
||||
conf_cookie.read = &conf_read;
|
||||
conf_cookie.write = NULL;
|
||||
conf_cookie.seek = NULL;
|
||||
conf_cookie.close = NULL;
|
||||
return fopencookie(NULL, "r", conf_cookie);
|
||||
}
|
||||
#elif defined(HAVE_FUNOPEN)
|
@ -3,14 +3,6 @@
|
||||
#ifndef _CONF_COOKIE_H
|
||||
#define _CONF_COOKIE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
FILE *conf_cookie_open(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CONF_COOKIE_H */
|
||||
|
264
src/conky.cc
264
src/conky.cc
@ -66,6 +66,9 @@
|
||||
#include <getopt.h>
|
||||
#ifdef BUILD_NCURSES
|
||||
#include <ncurses.h>
|
||||
#ifdef LEAKFREE_NCURSES
|
||||
#include "nc.h"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef BUILD_WEATHER_XOAP
|
||||
#include <libxml/parser.h>
|
||||
@ -686,18 +689,9 @@ struct conftree *currentconffile;
|
||||
static void extract_variable_text(const char *p)
|
||||
{
|
||||
free_text_objects(&global_root_object);
|
||||
if (tmpstring1) {
|
||||
free(tmpstring1);
|
||||
tmpstring1 = 0;
|
||||
}
|
||||
if (tmpstring2) {
|
||||
free(tmpstring2);
|
||||
tmpstring2 = 0;
|
||||
}
|
||||
if (text_buffer) {
|
||||
free(text_buffer);
|
||||
text_buffer = 0;
|
||||
}
|
||||
free_and_zero(tmpstring1);
|
||||
free_and_zero(tmpstring2);
|
||||
free_and_zero(text_buffer);
|
||||
|
||||
extract_variable_text_internal(&global_root_object, p);
|
||||
}
|
||||
@ -1497,7 +1491,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if (tmpcolour) free(tmpcolour);
|
||||
free_and_zero(tmpcolour);
|
||||
if (h > cur_y_add
|
||||
&& h > font_h) {
|
||||
cur_y_add = h;
|
||||
@ -2268,19 +2262,11 @@ static void main_loop(void)
|
||||
XFixesDestroyRegion(display, x11_stuff.region2);
|
||||
XFixesDestroyRegion(display, x11_stuff.part);
|
||||
#endif /* BUILD_XDAMAGE */
|
||||
if (disp) {
|
||||
free(disp);
|
||||
}
|
||||
free_and_zero(disp);
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
if(overwrite_file) {
|
||||
free(overwrite_file);
|
||||
overwrite_file = 0;
|
||||
}
|
||||
if(append_file) {
|
||||
free(append_file);
|
||||
append_file = 0;
|
||||
}
|
||||
free_and_zero(overwrite_file);
|
||||
free_and_zero(append_file);
|
||||
break;
|
||||
default:
|
||||
/* Reaching here means someone set a signal
|
||||
@ -2348,7 +2334,7 @@ static void main_loop(void)
|
||||
#endif /* BUILD_LUA */
|
||||
g_signal_pending = 0;
|
||||
}
|
||||
clean_up(NULL, NULL);
|
||||
clean_up(current_mail_spool, NULL);
|
||||
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
if (inotify_fd != -1) {
|
||||
@ -2387,18 +2373,11 @@ void clean_up(void *memtofree1, void* memtofree2)
|
||||
#endif
|
||||
conftree_empty(currentconffile);
|
||||
currentconffile = NULL;
|
||||
if(memtofree1) {
|
||||
free(memtofree1);
|
||||
}
|
||||
if(memtofree2) {
|
||||
free(memtofree2);
|
||||
}
|
||||
free_and_zero(memtofree1);
|
||||
free_and_zero(memtofree2);
|
||||
timed_thread::destroy_registered_threads();
|
||||
|
||||
if (info.cpu_usage) {
|
||||
free(info.cpu_usage);
|
||||
info.cpu_usage = NULL;
|
||||
}
|
||||
free_and_zero(info.cpu_usage);
|
||||
#ifdef BUILD_X11
|
||||
if (x_initialised == YES) {
|
||||
if(window_created == 1) {
|
||||
@ -2415,14 +2394,8 @@ void clean_up(void *memtofree1, void* memtofree2)
|
||||
}
|
||||
XCloseDisplay(display);
|
||||
display = NULL;
|
||||
if(info.x11.desktop.all_names) {
|
||||
free(info.x11.desktop.all_names);
|
||||
info.x11.desktop.all_names = NULL;
|
||||
}
|
||||
if (info.x11.desktop.name) {
|
||||
free(info.x11.desktop.name);
|
||||
info.x11.desktop.name = NULL;
|
||||
}
|
||||
free_and_zero(info.x11.desktop.all_names);
|
||||
free_and_zero(info.x11.desktop.name);
|
||||
x_initialised = NO;
|
||||
}else{
|
||||
free(fonts); //in set_default_configurations a font is set but not loaded
|
||||
@ -2443,26 +2416,11 @@ void clean_up(void *memtofree1, void* memtofree2)
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
free_text_objects(&global_root_object);
|
||||
if (tmpstring1) {
|
||||
free(tmpstring1);
|
||||
tmpstring1 = 0;
|
||||
}
|
||||
if (tmpstring2) {
|
||||
free(tmpstring2);
|
||||
tmpstring2 = 0;
|
||||
}
|
||||
if (text_buffer) {
|
||||
free(text_buffer);
|
||||
text_buffer = 0;
|
||||
}
|
||||
|
||||
if (global_text) {
|
||||
free(global_text);
|
||||
global_text = 0;
|
||||
}
|
||||
|
||||
free(current_config);
|
||||
current_config = 0;
|
||||
free_and_zero(tmpstring1);
|
||||
free_and_zero(tmpstring2);
|
||||
free_and_zero(text_buffer);
|
||||
free_and_zero(global_text);
|
||||
free_and_zero(current_config);
|
||||
|
||||
#ifdef BUILD_PORT_MONITORS
|
||||
tcp_portmon_clear();
|
||||
@ -2494,16 +2452,12 @@ void clean_up(void *memtofree1, void* memtofree2)
|
||||
free(specials[i].graph);
|
||||
}
|
||||
}
|
||||
free(specials);
|
||||
specials = NULL;
|
||||
free_and_zero(specials);
|
||||
}
|
||||
|
||||
clear_net_stats();
|
||||
clear_diskio_stats();
|
||||
if(global_cpu != NULL) {
|
||||
free(global_cpu);
|
||||
global_cpu = NULL;
|
||||
}
|
||||
free_and_zero(global_cpu);
|
||||
}
|
||||
|
||||
static int string_to_bool(const char *s)
|
||||
@ -2975,8 +2929,7 @@ char load_config_file(const char *f)
|
||||
if (!value || x_initialised == YES) {
|
||||
CONF_ERR;
|
||||
} else {
|
||||
if (disp)
|
||||
free(disp);
|
||||
free_and_zero(disp);
|
||||
disp = strdup(value);
|
||||
}
|
||||
}
|
||||
@ -3222,10 +3175,7 @@ char load_config_file(const char *f)
|
||||
}
|
||||
#endif
|
||||
CONF("overwrite_file") {
|
||||
if(overwrite_file) {
|
||||
free(overwrite_file);
|
||||
overwrite_file = 0;
|
||||
}
|
||||
free_and_zero(overwrite_file);
|
||||
if (overwrite_works(value)) {
|
||||
overwrite_file = strdup(value);
|
||||
output_methods |= OVERWRITE_FILE;
|
||||
@ -3233,10 +3183,7 @@ char load_config_file(const char *f)
|
||||
NORM_ERR("overwrite_file won't be able to create/overwrite '%s'", value);
|
||||
}
|
||||
CONF("append_file") {
|
||||
if(append_file) {
|
||||
free(append_file);
|
||||
append_file = 0;
|
||||
}
|
||||
free_and_zero(append_file);
|
||||
if(append_works(value)) {
|
||||
append_file = strdup(value);
|
||||
output_methods |= APPEND_FILE;
|
||||
@ -3329,9 +3276,7 @@ char load_config_file(const char *f)
|
||||
variable_substitute(value, buffer, 256);
|
||||
|
||||
if (buffer[0] != '\0') {
|
||||
if (current_mail_spool) {
|
||||
free(current_mail_spool);
|
||||
}
|
||||
free_and_zero(current_mail_spool);
|
||||
current_mail_spool = strndup(buffer, text_buffer_size);
|
||||
}
|
||||
} else {
|
||||
@ -3559,10 +3504,7 @@ char load_config_file(const char *f)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (global_text) {
|
||||
free(global_text);
|
||||
global_text = 0;
|
||||
}
|
||||
free_and_zero(global_text);
|
||||
|
||||
global_text = (char *) malloc(1);
|
||||
global_text[0] = '\0';
|
||||
@ -3945,6 +3887,7 @@ static void print_help(const char *prog_name) {
|
||||
" -x X x position\n"
|
||||
" -y Y y position\n"
|
||||
#endif /* BUILD_X11 */
|
||||
" -s, --for-scripts=TEXT render TEXT on stdout and exit, enclose TEXT by single quotes\n"
|
||||
" -t, --text=TEXT text to render, remember single quotes, like -t '$uptime'\n"
|
||||
" -u, --interval=SECS update interval\n"
|
||||
" -i COUNT number of times to update "PACKAGE_NAME" (and quit)\n"
|
||||
@ -3953,8 +3896,17 @@ static void print_help(const char *prog_name) {
|
||||
);
|
||||
}
|
||||
|
||||
inline void reset_optind() {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) \
|
||||
|| defined(__NetBSD__)
|
||||
optind = optreset = 1;
|
||||
#else
|
||||
optind = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* : means that character before that takes an argument */
|
||||
static const char *getopt_string = "vVqdDt:u:i:hc:p:"
|
||||
static const char *getopt_string = "vVqdDs:t:u:i:hc:p:"
|
||||
#ifdef BUILD_X11
|
||||
"x:y:w:a:f:X:"
|
||||
#ifdef OWN_WINDOW
|
||||
@ -3993,18 +3945,84 @@ static const struct option longopts[] = {
|
||||
#endif
|
||||
{ "window-id", 1, NULL, 'w' },
|
||||
#endif /* BUILD_X11 */
|
||||
{ "for-scripts", 1, NULL, 's' },
|
||||
{ "text", 1, NULL, 't' },
|
||||
{ "interval", 0, NULL, 'u' },
|
||||
{ "pause", 0, NULL, 'p' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
void set_current_config() {
|
||||
/* check if specified config file is valid */
|
||||
if (current_config) {
|
||||
struct stat sb;
|
||||
if (stat(current_config, &sb) ||
|
||||
(!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) {
|
||||
NORM_ERR("invalid configuration file '%s'\n", current_config);
|
||||
free_and_zero(current_config);
|
||||
}
|
||||
}
|
||||
|
||||
/* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */
|
||||
|
||||
if (!current_config) {
|
||||
/* load default config file */
|
||||
char buf[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
FILE *fp;
|
||||
|
||||
/* Try to use personal config file first */
|
||||
to_real_path(buf, CONFIG_FILE);
|
||||
if (buf[0] && (fp = fopen(buf, "r"))) {
|
||||
current_config = strndup(buf, max_user_text);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/* Try to use system config file if personal config not readable */
|
||||
if (!current_config && (fp = fopen(SYSTEM_CONFIG_FILE, "r"))) {
|
||||
current_config = strndup(SYSTEM_CONFIG_FILE, max_user_text);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/* No readable config found */
|
||||
if (!current_config) {
|
||||
#define NOCFGFILEFOUND "no readable personal or system-wide config file found"
|
||||
#ifdef BUILD_BUILTIN_CONFIG
|
||||
current_config = strdup("==builtin==");
|
||||
NORM_ERR(NOCFGFILEFOUND
|
||||
", using builtin default");
|
||||
#else
|
||||
CRIT_ERR(NULL, NULL, NOCFGFILEFOUND);
|
||||
#endif /* ! CONF_OUTPUT */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void initialisation(int argc, char **argv) {
|
||||
struct sigaction act, oact;
|
||||
bool for_scripts = false;
|
||||
|
||||
set_default_configurations();
|
||||
|
||||
reset_optind();
|
||||
while (1) {
|
||||
int c = getopt_long(argc, argv, getopt_string, longopts, NULL);
|
||||
|
||||
if (c == -1) {
|
||||
break;
|
||||
}else if (c == 's') {
|
||||
free_and_zero(global_text);
|
||||
global_text = strndup(optarg, max_user_text);
|
||||
convert_escapes(global_text);
|
||||
total_run_times = 1;
|
||||
output_methods = TO_STDOUT;
|
||||
for_scripts = true;
|
||||
}
|
||||
}
|
||||
if(for_scripts == false) {
|
||||
set_current_config();
|
||||
load_config_file(current_config);
|
||||
currentconffile = conftree_add(currentconffile, current_config);
|
||||
}
|
||||
|
||||
/* init specials array */
|
||||
if ((specials = (special_t*)calloc(sizeof(struct special_t), max_specials)) == 0) {
|
||||
@ -4025,12 +4043,7 @@ void initialisation(int argc, char **argv) {
|
||||
|
||||
/* handle other command line arguments */
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) \
|
||||
|| defined(__NetBSD__)
|
||||
optind = optreset = 1;
|
||||
#else
|
||||
optind = 0;
|
||||
#endif
|
||||
reset_optind();
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY,
|
||||
@ -4071,10 +4084,7 @@ void initialisation(int argc, char **argv) {
|
||||
#endif
|
||||
#endif /* BUILD_X11 */
|
||||
case 't':
|
||||
if (global_text) {
|
||||
free(global_text);
|
||||
global_text = 0;
|
||||
}
|
||||
free_and_zero(global_text);
|
||||
global_text = strndup(optarg, max_user_text);
|
||||
convert_escapes(global_text);
|
||||
break;
|
||||
@ -4121,11 +4131,7 @@ void initialisation(int argc, char **argv) {
|
||||
|
||||
/* generate text and get initial size */
|
||||
extract_variable_text(global_text);
|
||||
if (global_text) {
|
||||
free(global_text);
|
||||
global_text = 0;
|
||||
}
|
||||
global_text = NULL;
|
||||
free_and_zero(global_text);
|
||||
/* fork */
|
||||
if (fork_to_background && first_pass) {
|
||||
int pid = fork();
|
||||
@ -4252,9 +4258,7 @@ int main(int argc, char **argv)
|
||||
case 'V':
|
||||
print_version(); /* doesn't return */
|
||||
case 'c':
|
||||
if (current_config) {
|
||||
free(current_config);
|
||||
}
|
||||
free_and_zero(current_config);
|
||||
current_config = strndup(optarg, max_user_text);
|
||||
break;
|
||||
case 'q':
|
||||
@ -4274,8 +4278,7 @@ int main(int argc, char **argv)
|
||||
window.window = strtol(optarg, 0, 0);
|
||||
break;
|
||||
case 'X':
|
||||
if (disp)
|
||||
free(disp);
|
||||
free_and_zero(disp);
|
||||
disp = strdup(optarg);
|
||||
break;
|
||||
#endif /* BUILD_X11 */
|
||||
@ -4285,49 +4288,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* check if specified config file is valid */
|
||||
if (current_config) {
|
||||
struct stat sb;
|
||||
if (stat(current_config, &sb) ||
|
||||
(!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) {
|
||||
NORM_ERR("invalid configuration file '%s'\n", current_config);
|
||||
free(current_config);
|
||||
current_config = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */
|
||||
|
||||
if (!current_config) {
|
||||
/* load default config file */
|
||||
char buf[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
FILE *fp;
|
||||
|
||||
/* Try to use personal config file first */
|
||||
to_real_path(buf, CONFIG_FILE);
|
||||
if (buf[0] && (fp = fopen(buf, "r"))) {
|
||||
current_config = strndup(buf, max_user_text);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/* Try to use system config file if personal config not readable */
|
||||
if (!current_config && (fp = fopen(SYSTEM_CONFIG_FILE, "r"))) {
|
||||
current_config = strndup(SYSTEM_CONFIG_FILE, max_user_text);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/* No readable config found */
|
||||
if (!current_config) {
|
||||
#define NOCFGFILEFOUND "no readable personal or system-wide config file found"
|
||||
#ifdef BUILD_BUILTIN_CONFIG
|
||||
current_config = strdup("==builtin==");
|
||||
NORM_ERR(NOCFGFILEFOUND
|
||||
", using builtin default");
|
||||
#else
|
||||
CRIT_ERR(NULL, NULL, NOCFGFILEFOUND);
|
||||
#endif /* ! CONF_OUTPUT */
|
||||
}
|
||||
}
|
||||
set_current_config();
|
||||
|
||||
//////////// XXX ////////////////////////////////
|
||||
lua::state l;
|
||||
@ -4406,6 +4367,9 @@ int main(int argc, char **argv)
|
||||
kvm_close(kd);
|
||||
#endif
|
||||
|
||||
#ifdef LEAKFREE_NCURSES
|
||||
_nc_free_and_exit(0); //hide false memleaks
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
11
src/conky.h
11
src/conky.h
@ -209,7 +209,8 @@ struct information {
|
||||
double uptime;
|
||||
|
||||
/* memory information in kilobytes */
|
||||
unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
|
||||
unsigned long long mem, memwithbuffers, memeasyfree, memfree, memmax;
|
||||
unsigned long long swap, swapfree, swapmax;
|
||||
unsigned long long bufmem, buffers, cached;
|
||||
|
||||
unsigned short procs;
|
||||
@ -367,4 +368,12 @@ extern enum x_initialiser_state x_initialised;
|
||||
#define UNUSED(a) (void)a
|
||||
#define UNUSED_ATTR __attribute__ ((unused))
|
||||
|
||||
template <class T>
|
||||
void free_and_zero(T *&ptr) {
|
||||
if(ptr) {
|
||||
free(ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _conky_h_ */
|
||||
|
26
src/core.cc
26
src/core.cc
@ -241,7 +241,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
|
||||
#ifdef BUILD_WLAN
|
||||
END OBJ(wireless_essid, &update_net_stats)
|
||||
parse_net_stat_arg(obj, arg, free_at_crash);
|
||||
obj->data.opaque = get_net_stat(arg, obj, free_at_crash);
|
||||
obj->callbacks.print = &print_wireless_essid;
|
||||
END OBJ(wireless_mode, &update_net_stats)
|
||||
parse_net_stat_arg(obj, arg, free_at_crash);
|
||||
@ -442,7 +442,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
SCAN_CPU(arg, obj->data.i);
|
||||
buf = scan_graph(obj, arg, 1);
|
||||
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
|
||||
if (buf) free(buf);
|
||||
free_and_zero(buf);
|
||||
obj->callbacks.graphval = &cpu_barval;
|
||||
END OBJ(loadgraph, &update_load_average)
|
||||
scan_loadgraph_arg(obj, arg);
|
||||
@ -839,6 +839,8 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
obj->callbacks.free = &free_mboxscan;
|
||||
END OBJ(mem, &update_meminfo)
|
||||
obj->callbacks.print = &print_mem;
|
||||
END OBJ(memwithbuffers, &update_meminfo)
|
||||
obj->callbacks.print = &print_memwithbuffers;
|
||||
END OBJ(memeasyfree, &update_meminfo)
|
||||
obj->callbacks.print = &print_memeasyfree;
|
||||
END OBJ(memfree, &update_meminfo)
|
||||
@ -853,12 +855,15 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
END OBJ(membar, &update_meminfo)
|
||||
scan_bar(obj, arg, 1);
|
||||
obj->callbacks.barval = &mem_barval;
|
||||
END OBJ(memwithbuffersbar, &update_meminfo)
|
||||
scan_bar(obj, arg, 1);
|
||||
obj->callbacks.barval = &mem_with_buffers_barval;
|
||||
#ifdef BUILD_X11
|
||||
END OBJ(memgraph, &update_meminfo)
|
||||
char *buf = 0;
|
||||
buf = scan_graph(obj, arg, 1);
|
||||
|
||||
if (buf) free(buf);
|
||||
free_and_zero(buf);
|
||||
obj->callbacks.graphval = &mem_barval;
|
||||
#endif /* BUILD_X11*/
|
||||
END OBJ(mixer, 0)
|
||||
@ -1607,7 +1612,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long
|
||||
END OBJ(apcupsd_loadgraph, &update_apcupsd)
|
||||
char* buf = 0;
|
||||
buf = scan_graph(obj, arg, 100);
|
||||
if (buf) free(buf);
|
||||
free_and_zero(buf);
|
||||
obj->callbacks.graphval = &apcupsd_loadbarval;
|
||||
#endif /* BUILD_X11 */
|
||||
END OBJ(apcupsd_loadgauge, &update_apcupsd)
|
||||
@ -1846,24 +1851,19 @@ void free_text_objects(struct text_object *root)
|
||||
{
|
||||
struct text_object *obj;
|
||||
|
||||
if (!root->prev) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(root && root->prev) {
|
||||
for (obj = root->prev; obj; obj = root->prev) {
|
||||
root->prev = obj->prev;
|
||||
|
||||
if (obj->callbacks.free) {
|
||||
(*obj->callbacks.free)(obj);
|
||||
}
|
||||
if(obj->sub) {
|
||||
free_text_objects(obj->sub);
|
||||
free(obj->sub);
|
||||
}
|
||||
if(obj->special_data)
|
||||
free(obj->special_data);
|
||||
free_and_zero(obj->sub);
|
||||
free_and_zero(obj->special_data);
|
||||
|
||||
free(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,7 @@ void clear_diskio_stats(void)
|
||||
while (stats.next) {
|
||||
cur = stats.next;
|
||||
stats.next = stats.next->next;
|
||||
if (cur->dev)
|
||||
free(cur->dev);
|
||||
free_and_zero(cur->dev);
|
||||
free(cur);
|
||||
}
|
||||
}
|
||||
@ -150,8 +149,7 @@ void parse_diskiograph_arg(struct text_object *obj, const char *arg)
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
|
||||
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
|
||||
if (buf)
|
||||
free(buf);
|
||||
free_and_zero(buf);
|
||||
}
|
||||
|
||||
double diskiographval(struct text_object *obj)
|
||||
|
@ -437,8 +437,5 @@ void print_eve(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void free_eve(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
14
src/exec.cc
14
src/exec.cc
@ -204,8 +204,7 @@ static void threaded_exec(thread_handle &handle, struct text_object *obj)
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(handle.mutex());
|
||||
if (ed->buffer)
|
||||
free(ed->buffer);
|
||||
free_and_zero(ed->buffer);
|
||||
ed->buffer = buff;
|
||||
}
|
||||
if (handle.test(0)) {
|
||||
@ -364,10 +363,7 @@ double execi_barval(struct text_object *obj)
|
||||
|
||||
void free_exec(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.s) {
|
||||
free(obj->data.s);
|
||||
obj->data.s = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.s);
|
||||
}
|
||||
|
||||
void free_execi(struct text_object *obj)
|
||||
@ -380,10 +376,8 @@ void free_execi(struct text_object *obj)
|
||||
if (ed->p_timed_thread) {
|
||||
ed->p_timed_thread.reset();
|
||||
}
|
||||
if (ed->cmd)
|
||||
free(ed->cmd);
|
||||
if (ed->buffer)
|
||||
free(ed->buffer);
|
||||
free_and_zero(ed->cmd);
|
||||
free_and_zero(ed->buffer);
|
||||
delete ed;
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
|
@ -74,9 +74,7 @@ int add_font(const char *data_in)
|
||||
}
|
||||
font_count++;
|
||||
if (font_count == 0) {
|
||||
if (fonts != NULL) {
|
||||
free(fonts);
|
||||
}
|
||||
free_and_zero(fonts);
|
||||
if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
|
||||
== NULL) {
|
||||
CRIT_ERR(NULL, NULL, "malloc");
|
||||
@ -148,10 +146,7 @@ void free_fonts(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fonts) {
|
||||
free(fonts);
|
||||
fonts = 0;
|
||||
}
|
||||
free_and_zero(fonts);
|
||||
font_count = -1;
|
||||
selected_font = 0;
|
||||
#ifdef BUILD_XFT
|
||||
|
@ -177,6 +177,7 @@ void update_meminfo(void)
|
||||
|
||||
info.memmax = total_pages * (pagesize >> 10);
|
||||
info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
|
||||
info.memwithbuffers = info.mem;
|
||||
info.memeasyfree = info.memfree = info.memmax - info.mem;
|
||||
|
||||
if ((swapmode(&swap_avail, &swap_free)) >= 0) {
|
||||
|
@ -59,15 +59,13 @@ struct hdd_info hdd_info_head;
|
||||
|
||||
void set_hddtemp_host(const char *host)
|
||||
{
|
||||
if (hddtemp_host)
|
||||
free(hddtemp_host);
|
||||
free_and_zero(hddtemp_host);
|
||||
hddtemp_host = strdup(host);
|
||||
}
|
||||
|
||||
void set_hddtemp_port(const char *port)
|
||||
{
|
||||
if (hddtemp_port)
|
||||
free(hddtemp_port);
|
||||
free_and_zero(hddtemp_port);
|
||||
hddtemp_port = strdup(port);
|
||||
}
|
||||
|
||||
@ -237,18 +235,9 @@ void update_hddtemp(void) {
|
||||
void free_hddtemp(struct text_object *obj)
|
||||
{
|
||||
free_hddtemp_info();
|
||||
if (hddtemp_host) {
|
||||
free(hddtemp_host);
|
||||
hddtemp_host = NULL;
|
||||
}
|
||||
if (hddtemp_port) {
|
||||
free(hddtemp_port);
|
||||
hddtemp_port = NULL;
|
||||
}
|
||||
if (obj->data.s) {
|
||||
free(obj->data.s);
|
||||
obj->data.s = NULL;
|
||||
}
|
||||
free_and_zero(hddtemp_host);
|
||||
free_and_zero(hddtemp_port);
|
||||
free_and_zero(obj->data.s);
|
||||
}
|
||||
|
||||
static int get_hddtemp_info(const char *dev, short *val, char *unit)
|
||||
|
@ -485,12 +485,8 @@ void mpd_clearError(mpd_Connection *connection)
|
||||
void mpd_closeConnection(mpd_Connection *connection)
|
||||
{
|
||||
closesocket(connection->sock);
|
||||
if (connection->returnElement) {
|
||||
free(connection->returnElement);
|
||||
}
|
||||
if (connection->request) {
|
||||
free(connection->request);
|
||||
}
|
||||
free_and_zero(connection->returnElement);
|
||||
free_and_zero(connection->request);
|
||||
free(connection);
|
||||
WSACleanup();
|
||||
}
|
||||
@ -856,9 +852,7 @@ mpd_Status *mpd_getStatus(mpd_Connection *connection)
|
||||
|
||||
void mpd_freeStatus(mpd_Status *status)
|
||||
{
|
||||
if (status->error) {
|
||||
free(status->error);
|
||||
}
|
||||
free_and_zero(status->error);
|
||||
free(status);
|
||||
}
|
||||
|
||||
@ -1011,39 +1005,17 @@ static void mpd_initSong(mpd_Song *song)
|
||||
|
||||
static void mpd_finishSong(mpd_Song *song)
|
||||
{
|
||||
if (song->file) {
|
||||
free(song->file);
|
||||
}
|
||||
if (song->artist) {
|
||||
free(song->artist);
|
||||
}
|
||||
if (song->album) {
|
||||
free(song->album);
|
||||
}
|
||||
if (song->title) {
|
||||
free(song->title);
|
||||
}
|
||||
if (song->track) {
|
||||
free(song->track);
|
||||
}
|
||||
if (song->name) {
|
||||
free(song->name);
|
||||
}
|
||||
if (song->date) {
|
||||
free(song->date);
|
||||
}
|
||||
if (song->genre) {
|
||||
free(song->genre);
|
||||
}
|
||||
if (song->composer) {
|
||||
free(song->composer);
|
||||
}
|
||||
if (song->disc) {
|
||||
free(song->disc);
|
||||
}
|
||||
if (song->comment) {
|
||||
free(song->comment);
|
||||
}
|
||||
free_and_zero(song->file);
|
||||
free_and_zero(song->artist);
|
||||
free_and_zero(song->album);
|
||||
free_and_zero(song->title);
|
||||
free_and_zero(song->track);
|
||||
free_and_zero(song->name);
|
||||
free_and_zero(song->date);
|
||||
free_and_zero(song->genre);
|
||||
free_and_zero(song->composer);
|
||||
free_and_zero(song->disc);
|
||||
free_and_zero(song->comment);
|
||||
}
|
||||
|
||||
mpd_Song *mpd_newSong(void)
|
||||
@ -1112,9 +1084,7 @@ static void mpd_initDirectory(mpd_Directory *directory)
|
||||
|
||||
static void mpd_finishDirectory(mpd_Directory *directory)
|
||||
{
|
||||
if (directory->path) {
|
||||
free(directory->path);
|
||||
}
|
||||
free_and_zero(directory->path);
|
||||
}
|
||||
|
||||
mpd_Directory *mpd_newDirectory(void)
|
||||
@ -1151,9 +1121,7 @@ static void mpd_initPlaylistFile(mpd_PlaylistFile *playlist)
|
||||
|
||||
static void mpd_finishPlaylistFile(mpd_PlaylistFile *playlist)
|
||||
{
|
||||
if (playlist->path) {
|
||||
free(playlist->path);
|
||||
}
|
||||
free_and_zero(playlist->path);
|
||||
}
|
||||
|
||||
mpd_PlaylistFile *mpd_newPlaylistFile(void)
|
||||
@ -2084,8 +2052,7 @@ void mpd_commitSearch(mpd_Connection *connection)
|
||||
connection->request[len - 1] = '\0';
|
||||
mpd_sendInfoCommand(connection, connection->request);
|
||||
|
||||
free(connection->request);
|
||||
connection->request = NULL;
|
||||
free_and_zero(connection->request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
28
src/linux.cc
28
src/linux.cc
@ -76,7 +76,7 @@
|
||||
#define NBD_MAJOR 43
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IWLIB
|
||||
#ifdef BUILD_WLAN
|
||||
#include <iwlib.h>
|
||||
#endif
|
||||
|
||||
@ -161,8 +161,8 @@ void update_meminfo(void)
|
||||
/* unsigned int a; */
|
||||
char buf[256];
|
||||
|
||||
info.mem = info.memmax = info.swap = info.swapfree = info.swapmax = info.bufmem =
|
||||
info.buffers = info.cached = info.memfree = info.memeasyfree = 0;
|
||||
info.mem = info.memwithbuffers = info.memmax = info.swap = info.swapfree = info.swapmax =
|
||||
info.bufmem = info.buffers = info.cached = info.memfree = info.memeasyfree = 0;
|
||||
|
||||
if (!(meminfo_fp = open_file("/proc/meminfo", &rep))) {
|
||||
return;
|
||||
@ -188,7 +188,7 @@ void update_meminfo(void)
|
||||
}
|
||||
}
|
||||
|
||||
info.mem = info.memmax - info.memfree;
|
||||
info.mem = info.memwithbuffers = info.memmax - info.memfree;
|
||||
info.memeasyfree = info.memfree;
|
||||
info.swap = info.swapmax - info.swapfree;
|
||||
|
||||
@ -248,7 +248,6 @@ static struct {
|
||||
int count;
|
||||
} gw_info;
|
||||
|
||||
#define COND_FREE(x) if(x) free(x); x = 0
|
||||
#define SAVE_SET_STRING(x, y) \
|
||||
if (x && strcmp((char *)x, (char *)y)) { \
|
||||
free(x); \
|
||||
@ -279,8 +278,8 @@ void update_gateway_info(void)
|
||||
unsigned long dest, gate, mask;
|
||||
unsigned int flags;
|
||||
|
||||
COND_FREE(gw_info.iface);
|
||||
COND_FREE(gw_info.ip);
|
||||
free_and_zero(gw_info.iface);
|
||||
free_and_zero(gw_info.ip);
|
||||
gw_info.count = 0;
|
||||
|
||||
if ((fp = fopen("/proc/net/route", "r")) == NULL) {
|
||||
@ -315,10 +314,8 @@ void free_gateway_info(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
|
||||
if (gw_info.iface)
|
||||
free(gw_info.iface);
|
||||
if (gw_info.ip)
|
||||
free(gw_info.ip);
|
||||
free_and_zero(gw_info.iface);
|
||||
free_and_zero(gw_info.ip);
|
||||
memset(&gw_info, 0, sizeof(gw_info));
|
||||
}
|
||||
|
||||
@ -356,7 +353,7 @@ void update_net_stats(void)
|
||||
char buf[256];
|
||||
double delta;
|
||||
|
||||
#ifdef HAVE_IWLIB
|
||||
#ifdef BUILD_WLAN
|
||||
// wireless info variables
|
||||
int skfd, has_bitrate = 0;
|
||||
struct wireless_info *winfo;
|
||||
@ -496,9 +493,9 @@ void update_net_stats(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_IWLIB
|
||||
#ifdef BUILD_WLAN
|
||||
/* update wireless info */
|
||||
winfo = malloc(sizeof(struct wireless_info));
|
||||
winfo = (struct wireless_info *) malloc(sizeof(struct wireless_info));
|
||||
memset(winfo, 0, sizeof(struct wireless_info));
|
||||
|
||||
skfd = iw_sockets_open();
|
||||
@ -1116,8 +1113,7 @@ void free_sysfs_sensor(struct text_object *obj)
|
||||
return;
|
||||
|
||||
close(sf->fd);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
#define CPUFREQ_PREFIX "/sys/devices/system/cpu"
|
||||
|
24
src/llua.cc
24
src/llua.cc
@ -299,22 +299,10 @@ void llua_close(void)
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
llua_rm_notifies();
|
||||
#endif /* HAVE_SYS_INOTIFY_H */
|
||||
if (draw_pre_hook) {
|
||||
free(draw_pre_hook);
|
||||
draw_pre_hook = 0;
|
||||
}
|
||||
if (draw_post_hook) {
|
||||
free(draw_post_hook);
|
||||
draw_post_hook = 0;
|
||||
}
|
||||
if (startup_hook) {
|
||||
free(startup_hook);
|
||||
startup_hook = 0;
|
||||
}
|
||||
if (shutdown_hook) {
|
||||
free(shutdown_hook);
|
||||
shutdown_hook = 0;
|
||||
}
|
||||
free_and_zero(draw_pre_hook);
|
||||
free_and_zero(draw_post_hook);
|
||||
free_and_zero(startup_hook);
|
||||
free_and_zero(shutdown_hook);
|
||||
if(!lua_L) return;
|
||||
lua_close(lua_L);
|
||||
lua_L = NULL;
|
||||
@ -410,13 +398,13 @@ void llua_set_number(const char *key, double value)
|
||||
|
||||
void llua_set_startup_hook(const char *args)
|
||||
{
|
||||
if (startup_hook) free(startup_hook);
|
||||
free_and_zero(startup_hook);
|
||||
startup_hook = strdup(args);
|
||||
}
|
||||
|
||||
void llua_set_shutdown_hook(const char *args)
|
||||
{
|
||||
if (shutdown_hook) free(shutdown_hook);
|
||||
free_and_zero(shutdown_hook);
|
||||
shutdown_hook = strdup(args);
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOGGING_H
|
||||
#define _LOGGING_H
|
||||
|
||||
#include "mail.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void clean_up(void *memtofree1, void* memtofree2);
|
||||
|
||||
#ifndef _LOGGING_H
|
||||
#define _LOGGING_H
|
||||
|
||||
#define NORM_ERR(...) { \
|
||||
fprintf(stderr, PACKAGE_NAME": "); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
@ -44,7 +46,7 @@ void clean_up(void *memtofree1, void* memtofree2);
|
||||
|
||||
/* critical error */
|
||||
#define CRIT_ERR(memtofree1, memtofree2, ...) \
|
||||
{ NORM_ERR(__VA_ARGS__); clean_up(memtofree1, memtofree2); exit(EXIT_FAILURE); }
|
||||
{ NORM_ERR(__VA_ARGS__); clean_up(memtofree1, memtofree2); free(current_mail_spool); exit(EXIT_FAILURE); }
|
||||
|
||||
/* debugging output */
|
||||
extern int global_debug_level;
|
||||
|
@ -407,10 +407,8 @@ void free_local_mails(struct text_object *obj)
|
||||
if (!locmail)
|
||||
return;
|
||||
|
||||
if (locmail->mbox)
|
||||
free(locmail->mbox);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = 0;
|
||||
free_and_zero(locmail->mbox);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
#define MAXDATASIZE 1000
|
||||
|
@ -411,11 +411,8 @@ void free_mboxscan(struct text_object *obj)
|
||||
|
||||
if (!msd)
|
||||
return;
|
||||
if (msd->args)
|
||||
free(msd->args);
|
||||
if (msd->output)
|
||||
free(msd->output);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(msd->args);
|
||||
free_and_zero(msd->output);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
|
24
src/moc.cc
24
src/moc.cc
@ -31,8 +31,6 @@
|
||||
#include <string.h>
|
||||
#include <mutex>
|
||||
|
||||
#define xfree(x) if (x) free(x); x = 0
|
||||
|
||||
static struct {
|
||||
char *state;
|
||||
char *file;
|
||||
@ -52,17 +50,17 @@ static timed_thread_ptr moc_thread;
|
||||
void free_moc(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
xfree(moc.state);
|
||||
xfree(moc.file);
|
||||
xfree(moc.title);
|
||||
xfree(moc.artist);
|
||||
xfree(moc.song);
|
||||
xfree(moc.album);
|
||||
xfree(moc.totaltime);
|
||||
xfree(moc.timeleft);
|
||||
xfree(moc.curtime);
|
||||
xfree(moc.bitrate);
|
||||
xfree(moc.rate);
|
||||
free_and_zero(moc.state);
|
||||
free_and_zero(moc.file);
|
||||
free_and_zero(moc.title);
|
||||
free_and_zero(moc.artist);
|
||||
free_and_zero(moc.song);
|
||||
free_and_zero(moc.album);
|
||||
free_and_zero(moc.totaltime);
|
||||
free_and_zero(moc.timeleft);
|
||||
free_and_zero(moc.curtime);
|
||||
free_and_zero(moc.bitrate);
|
||||
free_and_zero(moc.rate);
|
||||
}
|
||||
|
||||
static void update_infos(void)
|
||||
|
14
src/mpd.cc
14
src/mpd.cc
@ -105,17 +105,15 @@ void init_mpd(void)
|
||||
|
||||
static void clear_mpd(void)
|
||||
{
|
||||
#define xfree(x) if (x) free(x)
|
||||
xfree(mpd_info.title);
|
||||
xfree(mpd_info.artist);
|
||||
xfree(mpd_info.album);
|
||||
free_and_zero(mpd_info.title);
|
||||
free_and_zero(mpd_info.artist);
|
||||
free_and_zero(mpd_info.album);
|
||||
/* do not free() the const char *status! */
|
||||
/* do not free() the const char *random! */
|
||||
/* do not free() the const char *repeat! */
|
||||
xfree(mpd_info.track);
|
||||
xfree(mpd_info.name);
|
||||
xfree(mpd_info.file);
|
||||
#undef xfree
|
||||
free_and_zero(mpd_info.track);
|
||||
free_and_zero(mpd_info.name);
|
||||
free_and_zero(mpd_info.file);
|
||||
memset(&mpd_info, 0, sizeof(mpd_info));
|
||||
}
|
||||
|
||||
|
11
src/nc.h
Normal file
11
src/nc.h
Normal file
@ -0,0 +1,11 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void _nc_free_and_exit(int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -226,8 +226,15 @@ void print_wireless_essid(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
struct net_stat *ns = (struct net_stat *)obj->data.opaque;
|
||||
|
||||
if (!ns)
|
||||
if (!ns) {
|
||||
for(unsigned int i = 0; *(netstats[i].dev) != 0; i++) {
|
||||
if(*(netstats[i].essid) != 0) {
|
||||
snprintf(p, p_max_size, "%s", netstats[i].essid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(p, p_max_size, "%s", ns->essid);
|
||||
}
|
||||
@ -306,9 +313,7 @@ void clear_net_stats(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_NET_INTERFACES; i++) {
|
||||
if (netstats[i].dev) {
|
||||
free(netstats[i].dev);
|
||||
}
|
||||
free_and_zero(netstats[i].dev);
|
||||
}
|
||||
memset(netstats, 0, sizeof(netstats));
|
||||
}
|
||||
@ -320,10 +325,7 @@ void parse_if_up_arg(struct text_object *obj, const char *arg)
|
||||
|
||||
void free_if_up(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
/* We should check if this is ok with OpenBSD and NetBSD as well. */
|
||||
|
@ -135,6 +135,7 @@ void update_meminfo()
|
||||
|
||||
info.memmax = (total_pages * pagesize) >> 10;
|
||||
info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
|
||||
info.memwithbuffers = info.mem;
|
||||
info.memeasyfree = info.memfree = info.memmax - info.mem;
|
||||
|
||||
if (swapmode(&swap_avail, &swap_free) >= 0) {
|
||||
|
@ -128,9 +128,6 @@ void print_nvidia_value(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void free_nvidia(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ void update_meminfo()
|
||||
}
|
||||
|
||||
info.memmax = pagetok(vmtotal.t_rm) + pagetok(vmtotal.t_free);
|
||||
info.mem = pagetok(vmtotal.t_rm);
|
||||
info.mem = info.memwithbuffers = pagetok(vmtotal.t_rm);
|
||||
info.memeasyfree = info.memfree = info.memmax - info.mem;
|
||||
|
||||
if ((swapmode(&swap_used, &swap_avail)) >= 0) {
|
||||
|
@ -32,6 +32,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include <limits.h> /* INT_MAX */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -69,7 +70,7 @@ struct prio_queue *init_prio_queue(void)
|
||||
{
|
||||
struct prio_queue *retval;
|
||||
|
||||
retval = malloc(sizeof(struct prio_queue));
|
||||
retval = (struct prio_queue *) malloc(sizeof(struct prio_queue));
|
||||
memset(retval, 0, sizeof(struct prio_queue));
|
||||
|
||||
/* use pq_free_nop by default */
|
||||
@ -110,7 +111,7 @@ static struct prio_elem *init_prio_elem(void *data)
|
||||
{
|
||||
struct prio_elem *retval;
|
||||
|
||||
retval = malloc(sizeof(struct prio_elem));
|
||||
retval = (struct prio_elem *) malloc(sizeof(struct prio_elem));
|
||||
memset(retval, 0, sizeof(struct prio_elem));
|
||||
|
||||
retval->data = data;
|
||||
@ -171,8 +172,7 @@ check_cur_size:
|
||||
queue->cur_size--;
|
||||
queue->tail = queue->tail->prev;
|
||||
(*queue->free)(queue->tail->next->data);
|
||||
free(queue->tail->next);
|
||||
queue->tail->next = NULL;
|
||||
free_and_zero(queue->tail->next);
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,6 @@
|
||||
#ifndef _PRIOQUEUE_H
|
||||
#define _PRIOQUEUE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* forward-define for private data */
|
||||
struct prio_queue;
|
||||
|
||||
@ -66,8 +63,4 @@ void *pop_prio_elem(prio_queue_t);
|
||||
/* clear and free the given queue */
|
||||
void free_prio_queue(prio_queue_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _PRIOQUEUE_H */
|
||||
|
29
src/prss.cc
29
src/prss.cc
@ -49,8 +49,9 @@ void free_rss_items(PRSS *data)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(data->items) {
|
||||
for (i = 0; i < data->item_count; i++) {
|
||||
#define CLEAR(a) if (data->items[i].a) { free(data->items[i].a); data->items[i].a = 0; }
|
||||
#define CLEAR(a) free_and_zero(data->items[i].a);
|
||||
CLEAR(title);
|
||||
CLEAR(link);
|
||||
CLEAR(description);
|
||||
@ -59,9 +60,9 @@ void free_rss_items(PRSS *data)
|
||||
CLEAR(guid);
|
||||
#undef CLEAR
|
||||
}
|
||||
free(data->items);
|
||||
free_and_zero(data->items);
|
||||
data->item_count = 0;
|
||||
data->items = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void prss_free(PRSS *data)
|
||||
@ -69,16 +70,10 @@ void prss_free(PRSS *data)
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (data->version) {
|
||||
free(data->version);
|
||||
data->version = 0;
|
||||
}
|
||||
if (data->items) {
|
||||
free_and_zero(data->version);
|
||||
free_rss_items(data);
|
||||
}
|
||||
data->version = 0;
|
||||
data->items = 0;
|
||||
#define CLEAR(a) if (data->a) { free(data->a); data->a = 0; }
|
||||
#define CLEAR(a) free_and_zero(data->a);
|
||||
CLEAR(title);
|
||||
CLEAR(link);
|
||||
CLEAR(description);
|
||||
@ -116,7 +111,7 @@ static inline void read_item(PRSS_Item *res, xmlNodePtr data)
|
||||
}
|
||||
|
||||
#define ASSIGN(a) if (strcasecmp((const char*)data->name, #a) == EQUAL) { \
|
||||
if (res->a) free(res->a); \
|
||||
free_and_zero(res->a); \
|
||||
res->a = strdup((const char*)child->content); \
|
||||
continue; \
|
||||
}
|
||||
@ -143,7 +138,7 @@ static inline void read_element(PRSS *res, xmlNodePtr n)
|
||||
}
|
||||
|
||||
#define ASSIGN(a) if (strcasecmp((const char*)n->name, #a) == EQUAL) { \
|
||||
if (res->a) free(res->a); \
|
||||
free_and_zero(res->a); \
|
||||
res->a = strdup((const char*)child->content); \
|
||||
return; \
|
||||
}
|
||||
@ -188,9 +183,9 @@ static inline int parse_rss_2_0(PRSS *res, xmlNodePtr root)
|
||||
}
|
||||
}
|
||||
|
||||
if (res->version) free(res->version);
|
||||
free_and_zero(res->version);
|
||||
res->version = strndup("2.0", text_buffer_size);
|
||||
if (res->items) free_rss_items(res);
|
||||
free_rss_items(res);
|
||||
res->items = (PRSS_Item*) malloc(items * sizeof(PRSS_Item));
|
||||
res->item_count = 0;
|
||||
|
||||
@ -221,9 +216,9 @@ static inline int parse_rss_1_0(PRSS *res, xmlNodePtr root)
|
||||
}
|
||||
}
|
||||
|
||||
if (res->version) free(res->version);
|
||||
free_and_zero(res->version);
|
||||
res->version = strndup("1.0", text_buffer_size);
|
||||
if (res->items) free_rss_items(res);
|
||||
free_rss_items(res);
|
||||
res->items = (PRSS_Item*) malloc(items * sizeof(PRSS_Item));
|
||||
res->item_count = 0;
|
||||
|
||||
|
@ -109,8 +109,6 @@ void free_read_tcp(struct text_object *obj)
|
||||
if (!rtd)
|
||||
return;
|
||||
|
||||
if (rtd->host)
|
||||
free(rtd->host);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(rtd->host);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
@ -183,8 +183,5 @@ void rss_print_info(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void rss_free_obj_info(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
@ -192,13 +192,8 @@ void free_scroll(struct text_object *obj)
|
||||
if (!sd)
|
||||
return;
|
||||
|
||||
if (sd->text)
|
||||
free(sd->text);
|
||||
if (obj->sub) {
|
||||
free_and_zero(sd->text);
|
||||
free_text_objects(obj->sub);
|
||||
free(obj->sub);
|
||||
obj->sub = NULL;
|
||||
}
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(obj->sub);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "text_object.h"
|
||||
@ -74,12 +75,9 @@ void free_tailhead(struct text_object *obj)
|
||||
struct headtail *ht = (struct headtail *)obj->data.opaque;
|
||||
if (!ht)
|
||||
return;
|
||||
if (ht->logfile)
|
||||
free(ht->logfile);
|
||||
if (ht->buffer)
|
||||
free(ht->buffer);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(ht->logfile);
|
||||
free_and_zero(ht->buffer);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
void init_tailhead(const char* type, const char* arg, struct text_object *obj, void* free_at_crash) {
|
||||
@ -125,8 +123,7 @@ static void print_tailhead(const char* type, struct text_object *obj, char *p, i
|
||||
|
||||
//empty the buffer and reset the counter if we used it the max number of times
|
||||
if(ht->buffer && ht->current_use >= ht->max_uses - 1) {
|
||||
free(ht->buffer);
|
||||
ht->buffer = NULL;
|
||||
free_and_zero(ht->buffer);
|
||||
ht->current_use = 0;
|
||||
}
|
||||
//use the buffer if possible
|
||||
|
@ -156,8 +156,5 @@ int tcp_portmon_set_max_connections(int max)
|
||||
|
||||
void tcp_portmon_free(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
@ -53,10 +53,7 @@ void free_templates(void)
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_TEMPLATES; i++) {
|
||||
if (_template[i]) {
|
||||
free(_template[i]);
|
||||
_template[i] = NULL;
|
||||
}
|
||||
free_and_zero(_template[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,8 +64,7 @@ int set_template(int n, const char *val)
|
||||
{
|
||||
if (n < 0 || n >= MAX_TEMPLATES || !val)
|
||||
return 1;
|
||||
if (_template[n])
|
||||
free(_template[n]);
|
||||
free_and_zero(_template[n]);
|
||||
_template[n] = strdup(val);
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#include "conky.h"
|
||||
#include "config.h"
|
||||
#include "text_object.h"
|
||||
#include "logging.h"
|
||||
@ -35,8 +36,7 @@
|
||||
|
||||
void gen_free_opaque(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque)
|
||||
free(obj->data.opaque);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
int gen_false_iftest(struct text_object *obj)
|
||||
|
@ -133,10 +133,7 @@ void print_tztime(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void free_time(struct text_object *obj)
|
||||
{
|
||||
if (!obj->data.opaque)
|
||||
return;
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
void free_tztime(struct text_object *obj)
|
||||
@ -146,13 +143,10 @@ void free_tztime(struct text_object *obj)
|
||||
if (!ts)
|
||||
return;
|
||||
|
||||
if (ts->tz)
|
||||
free(ts->tz);
|
||||
if (ts->fmt)
|
||||
free(ts->fmt);
|
||||
free_and_zero(ts->tz);
|
||||
free_and_zero(ts->fmt);
|
||||
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
/* a safer asprintf()
|
||||
|
21
src/top.cc
21
src/top.cc
@ -116,9 +116,7 @@ void free_all_processes(void)
|
||||
|
||||
while (pr) {
|
||||
next = pr->next;
|
||||
if (pr->name) {
|
||||
free(pr->name);
|
||||
}
|
||||
free_and_zero(pr->name);
|
||||
free(pr);
|
||||
pr = next;
|
||||
}
|
||||
@ -280,9 +278,7 @@ static int process_parse_stat(struct process *process)
|
||||
*q = 0;
|
||||
}
|
||||
|
||||
if (process->name) {
|
||||
free(process->name);
|
||||
}
|
||||
free_and_zero(process->name);
|
||||
process->name = strndup(procname, text_buffer_size);
|
||||
process->rss *= getpagesize();
|
||||
|
||||
@ -487,9 +483,7 @@ static void delete_process(struct process *p)
|
||||
else
|
||||
first_process = p->next;
|
||||
|
||||
if (p->name) {
|
||||
free(p->name);
|
||||
}
|
||||
free_and_zero(p->name);
|
||||
/* remove the process from the hash table */
|
||||
unhash_process(p);
|
||||
free(p);
|
||||
@ -874,10 +868,8 @@ static void free_top(struct text_object *obj)
|
||||
|
||||
if (!td)
|
||||
return;
|
||||
if (td->s)
|
||||
free(td->s);
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
free_and_zero(td->s);
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
||||
int parse_top_args(const char *s, const char *arg, struct text_object *obj)
|
||||
@ -914,8 +906,7 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj)
|
||||
#else /* BUILD_IOSTATS */
|
||||
NORM_ERR("Must be top, top_mem or top_time");
|
||||
#endif /* BUILD_IOSTATS */
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = 0;
|
||||
free_and_zero(obj->data.opaque);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
63
src/users.cc
63
src/users.cc
@ -141,17 +141,11 @@ static void update_user_time(char *tty)
|
||||
tty_user_time(temp, tty);
|
||||
|
||||
if (temp != NULL) {
|
||||
if (current_info->users.ctime) {
|
||||
free(current_info->users.ctime);
|
||||
current_info->users.ctime = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.ctime);
|
||||
current_info->users.ctime = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.ctime, temp, text_buffer_size);
|
||||
} else {
|
||||
if (current_info->users.ctime) {
|
||||
free(current_info->users.ctime);
|
||||
current_info->users.ctime = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.ctime);
|
||||
current_info->users.ctime = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.ctime, "broken", text_buffer_size);
|
||||
}
|
||||
@ -165,17 +159,11 @@ void update_users(void)
|
||||
users_alloc(current_info);
|
||||
user_name(temp);
|
||||
if (temp != NULL) {
|
||||
if (current_info->users.names) {
|
||||
free(current_info->users.names);
|
||||
current_info->users.names = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.names);
|
||||
current_info->users.names = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.names, temp, text_buffer_size);
|
||||
} else {
|
||||
if (current_info->users.names) {
|
||||
free(current_info->users.names);
|
||||
current_info->users.names = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.names);
|
||||
current_info->users.names = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.names, "broken", text_buffer_size);
|
||||
}
|
||||
@ -191,33 +179,21 @@ void update_users(void)
|
||||
temp[0] = 0;
|
||||
user_term(temp);
|
||||
if (temp != NULL) {
|
||||
if (current_info->users.terms) {
|
||||
free(current_info->users.terms);
|
||||
current_info->users.terms = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.terms);
|
||||
current_info->users.terms = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.terms, temp, text_buffer_size);
|
||||
} else {
|
||||
if (current_info->users.terms) {
|
||||
free(current_info->users.terms);
|
||||
current_info->users.terms = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.terms);
|
||||
current_info->users.terms = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.terms, "broken", text_buffer_size);
|
||||
}
|
||||
user_time(temp);
|
||||
if (temp != NULL) {
|
||||
if (current_info->users.times) {
|
||||
free(current_info->users.times);
|
||||
current_info->users.times = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.times);
|
||||
current_info->users.times = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.times, temp, text_buffer_size);
|
||||
} else {
|
||||
if (current_info->users.times) {
|
||||
free(current_info->users.times);
|
||||
current_info->users.times = 0;
|
||||
}
|
||||
free_and_zero(current_info->users.times);
|
||||
current_info->users.times = (char*)malloc(text_buffer_size);
|
||||
strncpy(current_info->users.times, "broken", text_buffer_size);
|
||||
}
|
||||
@ -256,36 +232,23 @@ void print_user_number(struct text_object *obj, char *p, int p_max_size)
|
||||
void free_user_names(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
if (info.users.names) {
|
||||
free(info.users.names);
|
||||
info.users.names = 0;
|
||||
}
|
||||
free_and_zero(info.users.names);
|
||||
}
|
||||
|
||||
void free_user_terms(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
if (info.users.terms) {
|
||||
free(info.users.terms);
|
||||
info.users.terms = 0;
|
||||
}
|
||||
free_and_zero(info.users.terms);
|
||||
}
|
||||
|
||||
void free_user_times(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
if (info.users.times) {
|
||||
free(info.users.times);
|
||||
info.users.times = 0;
|
||||
}
|
||||
free_and_zero(info.users.times);
|
||||
}
|
||||
|
||||
void free_user_time(struct text_object *obj)
|
||||
{
|
||||
if (info.users.ctime) {
|
||||
free(info.users.ctime);
|
||||
info.users.ctime = 0;
|
||||
}
|
||||
if (obj->data.s)
|
||||
free(obj->data.s);
|
||||
free_and_zero(info.users.ctime);
|
||||
free_and_zero(obj->data.s);
|
||||
}
|
||||
|
@ -1010,8 +1010,5 @@ void print_weather(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void free_weather(struct text_object *obj)
|
||||
{
|
||||
if (obj->data.opaque) {
|
||||
free(obj->data.opaque);
|
||||
obj->data.opaque = NULL;
|
||||
}
|
||||
free_and_zero(obj->data.opaque);
|
||||
}
|
||||
|
20
src/x11.cc
20
src/x11.cc
@ -698,10 +698,7 @@ static inline void get_x11_desktop_names(Display *current_display, Window root,
|
||||
(actual_type == ATOM(UTF8_STRING)) &&
|
||||
(nitems > 0L) && (actual_format == 8) ) {
|
||||
|
||||
if(current_info->x11.desktop.all_names) {
|
||||
free(current_info->x11.desktop.all_names);
|
||||
current_info->x11.desktop.all_names = NULL;
|
||||
}
|
||||
free_and_zero(current_info->x11.desktop.all_names);
|
||||
current_info->x11.desktop.all_names = (char*)malloc(nitems*sizeof(char));
|
||||
memcpy(current_info->x11.desktop.all_names, prop, nitems);
|
||||
current_info->x11.desktop.nitems = nitems;
|
||||
@ -721,10 +718,7 @@ static inline void get_x11_desktop_current_name(char *names)
|
||||
while ( i < current_info->x11.desktop.nitems ) {
|
||||
if ( names[i++] == '\0' ) {
|
||||
if ( ++k == current_info->x11.desktop.current ) {
|
||||
if (current_info->x11.desktop.name) {
|
||||
free(current_info->x11.desktop.name);
|
||||
current_info->x11.desktop.name = NULL;
|
||||
}
|
||||
free_and_zero(current_info->x11.desktop.name);
|
||||
current_info->x11.desktop.name = (char*)malloc((i-j)*sizeof(char));
|
||||
//desktop names can be empty but should always be not null
|
||||
strcpy( current_info->x11.desktop.name, (char *)&names[j] );
|
||||
@ -834,14 +828,8 @@ void print_desktop_name(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
void free_desktop_info(void)
|
||||
{
|
||||
if(info.x11.desktop.name) {
|
||||
free(info.x11.desktop.name);
|
||||
info.x11.desktop.name = NULL;
|
||||
}
|
||||
if(info.x11.desktop.all_names) {
|
||||
free(info.x11.desktop.all_names);
|
||||
info.x11.desktop.all_names = NULL;
|
||||
}
|
||||
free_and_zero(info.x11.desktop.name);
|
||||
free_and_zero(info.x11.desktop.all_names);
|
||||
}
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
|
19
src/xmms2.cc
19
src/xmms2.cc
@ -84,20 +84,19 @@ static void xmms_alloc(struct information *ptr)
|
||||
ptr->xmms2.timesplayed = -1;
|
||||
}
|
||||
|
||||
#define xfree(x) if (x) { free(x); x = 0; }
|
||||
void free_xmms2(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
|
||||
xfree(info.xmms2.artist);
|
||||
xfree(info.xmms2.album);
|
||||
xfree(info.xmms2.title);
|
||||
xfree(info.xmms2.genre);
|
||||
xfree(info.xmms2.comment);
|
||||
xfree(info.xmms2.url);
|
||||
xfree(info.xmms2.date);
|
||||
xfree(info.xmms2.status);
|
||||
xfree(info.xmms2.playlist);
|
||||
free_and_zero(info.xmms2.artist);
|
||||
free_and_zero(info.xmms2.album);
|
||||
free_and_zero(info.xmms2.title);
|
||||
free_and_zero(info.xmms2.genre);
|
||||
free_and_zero(info.xmms2.comment);
|
||||
free_and_zero(info.xmms2.url);
|
||||
free_and_zero(info.xmms2.date);
|
||||
free_and_zero(info.xmms2.status);
|
||||
free_and_zero(info.xmms2.playlist);
|
||||
}
|
||||
|
||||
void connection_lost(void *p)
|
||||
|
Loading…
Reference in New Issue
Block a user