| 3746 | } |
| 3747 | |
| 3748 | int bsgs_searchbinary(struct bsgs_xvalue *buffer,char *data,int64_t array_length,uint64_t *r_value) { |
| 3749 | int64_t min,max,half,current; |
| 3750 | int r = 0,rcmp; |
| 3751 | min = 0; |
| 3752 | current = 0; |
| 3753 | max = array_length; |
| 3754 | half = array_length; |
| 3755 | while(!r && half >= 1) { |
| 3756 | half = (max - min)/2; |
| 3757 | rcmp = memcmp(data+16,buffer[current+half].value,BSGS_XVALUE_RAM); |
| 3758 | if(rcmp == 0) { |
| 3759 | *r_value = buffer[current+half].index; |
| 3760 | r = 1; |
| 3761 | } |
| 3762 | else { |
| 3763 | if(rcmp < 0) { |
| 3764 | max = (max-half); |
| 3765 | } |
| 3766 | else { |
| 3767 | min = (min+half); |
| 3768 | } |
| 3769 | current = min; |
| 3770 | } |
| 3771 | } |
| 3772 | return r; |
| 3773 | } |
| 3774 | |
| 3775 | #if defined(_WIN64) && !defined(__CYGWIN__) |
| 3776 | DWORD WINAPI thread_process_bsgs(LPVOID vargp) { |