I added a BITPOS operation to Redis, which accepts [start end limit] arguments. As the name suggests, it operates on bit strings and returns the positions (offsets) of all the set bits. My C is a little rusty, so it might need a little review/improvements.
[start end limit]
Added BITPOS command
The lack of explicit memory allocation and validation in this patch crashes Redis, especially on large bit sets. As a temporary, intermediate, array of set bit positions isn't actually required, this patch eliminates the crash behavior as well as exhibits substantially improved performance (by eliminating the allocation). If you're still using the command, please check it out: #1295