Skip to content

Commit f35edf5

Browse files
authored
demo(calloc): make function shorter for sgx (#129)
In order to make the function run in tractable time in SGX HW mode, reduce the number of iterations it does.
1 parent 0c8c17c commit f35edf5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

func/demo/calloc.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
int main(int argc, char* argv[])
1414
{
1515
int callocSize = 100;
16-
int n = 1000;
16+
int n = 100;
1717
char* callocPtrs[n];
1818
char* mmapPtrs[n];
1919
int mmapLen = 20;
2020

2121
// Use calloc to allocate lots of smaller memory regions
22-
for (int i = 0; i < 1000; i++) {
22+
for (int i = 0; i < n; i++) {
2323
char* callocPtr = (char*)calloc(1, callocSize);
2424
std::string s = "number ";
2525
s += std::to_string(i);
@@ -38,7 +38,7 @@ int main(int argc, char* argv[])
3838
}
3939

4040
// Go back through and check everything is still intact
41-
for (int j = 0; j < 1000; j++) {
41+
for (int j = 0; j < n; j++) {
4242
char* nextPtr = callocPtrs[j];
4343
std::string actual(nextPtr);
4444
std::string expected = "number ";

0 commit comments

Comments
 (0)