Skip to content

Commit

Permalink
demo(calloc): make function shorter for sgx
Browse files Browse the repository at this point in the history
In order to make the function run in tractable time in SGX HW mode,
reduce the number of iterations it does.
  • Loading branch information
csegarragonz committed Oct 9, 2024
1 parent 0c8c17c commit 633a00d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions func/demo/calloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
int main(int argc, char* argv[])
{
int callocSize = 100;
int n = 1000;
int n = 100;
char* callocPtrs[n];
char* mmapPtrs[n];
int mmapLen = 20;

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

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

0 comments on commit 633a00d

Please sign in to comment.