- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to allocate a buffer inside an enclave by using new in an ecall function as follows
This is what I have in Enclave.edl
public int buffer_allocator([out, size=len] char * buffer, size_t len);
And this is what I defined in Enclave.cpp
// to allocate a buffer in EPC
// to allocate a buffer in EPC int buffer_allocator(char * buffer, size_t len) { buffer = new char[len]; if (!buffer) return (1); else return(0); }
However, when I am running it, it returns 0 meaning that it fails to allocate memory. The question is how to allocate a buffer inside the enclave?
- Tags:
- General Support
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
That will allocate the buffer just fine, provided you have set up enough enclave heap size in the Enclave.config.xml for the length of buffer you're trying to allocate.
I think the problem is that you have your null check logic (or return values) backward, which is why you are getting a zero returned... It should be "if (buffer) return 1;" or "if (!buffer) return 0;".
Regards.
Scott
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page