Last active
August 10, 2017 15:30
-
-
Save dimenus/874355a2a50f6f7b474e8774a62643a7 to your computer and use it in GitHub Desktop.
traversal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(counter == buf_len) { | |
//this bit (31) gets set when we've hit the end of a valid word | |
*current_slot |= (1 << 31); | |
break; | |
} | |
//if we're not at the end of a word and memory hasn't been allocated for the next level | |
//set bit 30 and get memory from the pool | |
if((*current_slot & (1 << 30)) == 0) { | |
*current_slot += MemoryPoolOffset + (1 << 30); | |
MemoryPoolOffset += stride_size; | |
assert(MemoryPoolOffset < pool_size); | |
} | |
offset = abs(tolower(buffer[counter]) - 'a'); | |
if(offset > 26) { | |
offset = 26; | |
} | |
//Set the current slot pointer to the address of the bottom 30 bits of the existing value + MemoryPool + (array)offset | |
//u32* is 8 bytes wide on x86_64 | |
current_slot = (u32*)(((*current_slot) & ~(0b11 << 30)) + (u64)MemoryPool + (offset * sizeof(u32))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment