0

after implementing speller.c with a trie and a hashtable, I thought I'll give it a shot to use memory mapping. After reading the man page and some further research I had an idea of what to do and adapted my code where I used malloc() to this

It compiles but running it returns me this error:

==16185==ERROR: UndefinedBehaviorSanitizer failed to allocate 0x1000 (4096) bytes of InternalScopedBuffer (error code: 12) 
ERROR: Failed to mmap

However, if I pass it to check50 it passes all tests.

What I already know is, that using mmap() the way I do it is a horrible waste of memory, as I allocate 4096 Bytes for each node, where I only need 56 (that's what sizeof(node) returns). That should be the reason why it is not running in my cs50 IDE but does so if I pass it to check50?

Can I just allocate 143000ish*sizeof(node) Bytes via mmap() and then somehow assign the addresses manually? Or what is the way to go there?

Thanks for your help.

1

Pointer arithmetic was the keyword I was looking for. See this

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .