Skip to content

Commit

Permalink
improve memory display in xgap
Browse files Browse the repository at this point in the history
This patch changes the memory display in xgap to always be in MB, in the form "128.3".  I also changed from sprintf to the slightly safer snprintf.  (I considered increasing the tmp buffer size, but did not.)
  • Loading branch information
RussWoodroofe authored and fingolfin committed Nov 10, 2018
1 parent d995895 commit 1ffdf5a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src.x11/xgap.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,17 @@ void UpdateMemoryInfo ( type, val )
switch ( type )
{
case 1:
sprintf( tmp, "Objects: %-5d ", val );
snprintf( tmp, sizeof(tmp), "Objects: %-5d ", val );
XtVaSetValues( LabelLiveObjects, XtNlabel, (XtArgVal)tmp,
(String)NULL );
break;
case 2:
sprintf( tmp, "KB used: %-5d ", val );
snprintf( tmp, sizeof(tmp), "MB used: %.1f ", val/(float)1024 );
XtVaSetValues( LabelLiveKB, XtNlabel, (XtArgVal)tmp,
(String)NULL );
break;
case 6:
sprintf( tmp, "MBytes total: %-4d ", val/1024 );
snprintf( tmp, sizeof(tmp), "MB total: %.1f ", val/(float)1024 );
XtVaSetValues( LabelTotalKBytes, XtNlabel, (XtArgVal)tmp,
(String)NULL );
break;
Expand Down

0 comments on commit 1ffdf5a

Please sign in to comment.