mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-05 06:20:10 +00:00
30 lines
556 B
C++
30 lines
556 B
C++
// ASE base library
|
|
// Copyright (C) 2001-2011 David Capello
|
|
//
|
|
// This source file is ditributed under a BSD-like license, please
|
|
// read LICENSE.txt for more information.
|
|
|
|
#include "config.h"
|
|
|
|
#include <string>
|
|
#include <cstdio>
|
|
|
|
using namespace std;
|
|
|
|
string get_pretty_memory_size(size_t memsize)
|
|
{
|
|
char buf[256];
|
|
|
|
if (memsize < 1000) {
|
|
sprintf(buf, "%d bytes", memsize);
|
|
}
|
|
else if (memsize < 1000*1000) {
|
|
sprintf(buf, "%0.1fK", memsize/1024.0f);
|
|
}
|
|
else {
|
|
sprintf(buf, "%0.1fM", memsize/(1024.0f*1024.0f));
|
|
}
|
|
|
|
return buf;
|
|
}
|