Commit f8ab22b9 by liyinqiao

Support more sizes of memory pool and clean the codes.

1. Support KB size for memory pool.
2. Clean the codes: 1000000 -> 1024 * 1024.
parent 0bf05532
......@@ -100,7 +100,7 @@ namespace nts {
} \
#define MAX_FILE_NAME_LENGTH 1024 * 2
#define MAX_LINE_LENGTH 1024*1024
#define MAX_LINE_LENGTH 1024 * 1024
#define MAX_SENTENCE_LEN 512
#define X_MILLION 1000000
#define MAX_INT 2147483647
......@@ -108,7 +108,7 @@ namespace nts {
#define FIELD_SEP " ||| "
#define FLOAT_MIN float(-1.0E38)
#define FLOAT16_MIN float(-65504)
#define MILLION 1000000
#define MILLION 1024 * 1024
#define LOG_E_10 2.302585
#define LEADING_DIM 1
......
......@@ -1400,17 +1400,38 @@ MTYPE XMem::GetMemSize(const char * size)
bool ok = false;
float num = 0;
if(s[len-2] == 'm' && s[len-1] == 'b'){
s[len-2] = 0;
num = (float)atof(s);
ok = true;
if (s[len-1] == 'b') {
if (s[len-2] == 'k') {
s[len-2] = 0;
num = (float)atof(s);
num /= 1024.0F;
ok = true;
}
else if (s[len-2] == 'm') {
s[len-2] = 0;
num = (float)atof(s);
ok = true;
}
else if (s[len-2] == 'g') {
s[len-2] = 0;
num = (float)atof(s);
num *= 1024.0F;
ok = true;
}
else if (s[len-2] >= '0' && s[len-2] <= '9') {
s[len-1] = 0;
num = (float)atof(s);
ok = true;
}
else
ShowNTErrors("Cannot transform the size into a number (in million)!");
}
if(s[len-2] == 'g' && s[len-1] == 'b'){
s[len-2] = 0;
else if (s[len-1] >= '0' && s[len-1] <= '9') {
num = (float)atof(s);
num *= 1000.0F;
ok = true;
}
else
ShowNTErrors("Cannot transform the size into a number (in million)!");
delete[] s;
......@@ -1433,18 +1454,25 @@ MTYPE XMem::GetMemSizeInBytes(const char * size)
bool ok = false;
float num = 0;
if(s[len-2] == 'm' && s[len-1] == 'b'){
num = (float)GetMemSize(size) * 1000000;
ok = true;
}
else if(s[len-2] == 'g' && s[len-1] == 'b'){
num = (float)GetMemSize(size) * 1000000;
ok = true;
if (s[len-1] == 'b') {
if (s[len-2] == 'k' || s[len-2] == 'm' || s[len-2] == 'g') {
num = (float)GetMemSize(size) * 1024 * 1024;
ok = true;
}
else if (s[len-2] >= '0' && s[len-2] <= '9') {
s[len-1] = 0;
num = (float)atof(s);
ok = true;
}
else
ShowNTErrors("Cannot transform the size into a number (in Bytes)!");
}
else{
else if (s[len-1] >= '0' && s[len-1] <= '9') {
num = (float)atof(s);
ok = true;
}
else
ShowNTErrors("Cannot transform the size into a number (in Bytes)!");
delete[] s;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论