Skip to content

Commit

Permalink
rpm: fix statistics name and crash when not used
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Mar 29, 2019
1 parent 9328335 commit 38d7339
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
18 changes: 9 additions & 9 deletions mem/rpm_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ stat_var *rpm_frags;

#ifdef STATISTICS
stat_export_t rpm_stats[] = {
{"total_size" , STAT_IS_FUNC, (stat_var**)rpm_get_size },
{"rpm_total_size" , STAT_IS_FUNC, (stat_var**)rpm_get_size },

#if defined(HP_MALLOC)
{"used_size" , STAT_NO_RESET, &rpm_used },
{"real_used_size" ,STAT_NO_RESET, &rpm_rused },
{"rpm_used_size" , STAT_NO_RESET, &rpm_used },
{"rpm_real_used_size" ,STAT_NO_RESET, &rpm_rused },
#else
{"used_size" , STAT_IS_FUNC, (stat_var**)rpm_get_used },
{"real_used_size" , STAT_IS_FUNC, (stat_var**)rpm_get_rused },
{"rpm_used_size" , STAT_IS_FUNC, (stat_var**)rpm_get_used },
{"rpm_real_used_size" , STAT_IS_FUNC, (stat_var**)rpm_get_rused },
#endif

{"max_used_size" , STAT_IS_FUNC, (stat_var**)rpm_get_mused },
{"free_size" , STAT_IS_FUNC, (stat_var**)rpm_get_free },
{"rpm_max_used_size" , STAT_IS_FUNC, (stat_var**)rpm_get_mused },
{"rpm_free_size" , STAT_IS_FUNC, (stat_var**)rpm_get_free },

#if defined(HP_MALLOC)
{"fragments" , STAT_NO_RESET, &rpm_frags },
{"rpm_fragments" , STAT_NO_RESET, &rpm_frags },
#else
{"fragments" , STAT_IS_FUNC, (stat_var**)rpm_get_frags },
{"rpm_fragments" , STAT_IS_FUNC, (stat_var**)rpm_get_frags },
#endif

{0,0,0}
Expand Down
12 changes: 12 additions & 0 deletions mem/rpm_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,33 @@ void hp_init_rpm_statistics(struct hp_block *hpb);
extern stat_export_t rpm_stats[];

inline static unsigned long rpm_get_size(unsigned short foo) {
if (!rpm_block)
return 0;
return RPM_GET_SIZE(rpm_block);
}
inline static unsigned long rpm_get_used(unsigned short foo) {
if (!rpm_block)
return 0;
return RPM_GET_USED(rpm_block);
}
inline static unsigned long rpm_get_rused(unsigned short foo) {
if (!rpm_block)
return 0;
return RPM_GET_RUSED(rpm_block);
}
inline static unsigned long rpm_get_mused(unsigned short foo) {
if (!rpm_block)
return 0;
return RPM_GET_MUSED(rpm_block);
}
inline static unsigned long rpm_get_free(unsigned short foo) {
if (!rpm_block)
return 0;
return RPM_GET_FREE(rpm_block);
}
inline static unsigned long rpm_get_frags(unsigned short foo) {
if (!rpm_block)
return 0;
return RPM_GET_FRAGS(rpm_block);
}
#endif /*STATISTICS*/
Expand Down

0 comments on commit 38d7339

Please sign in to comment.