| 1546 | } |
| 1547 | |
| 1548 | int bsgs_searchbinary(struct bsgs_xvalue *buffer,char *data,int64_t array_length,uint64_t *r_value) { |
| 1549 | int64_t min,max,half,current; |
| 1550 | int r = 0,rcmp; |
| 1551 | min = 0; |
| 1552 | current = 0; |
| 1553 | max = array_length; |
| 1554 | half = array_length; |
| 1555 | while(!r && half >= 1) { |
| 1556 | half = (max - min)/2; |
| 1557 | rcmp = memcmp(data+16,buffer[current+half].value,BSGS_XVALUE_RAM); |
| 1558 | if(rcmp == 0) { |
| 1559 | *r_value = buffer[current+half].index; |
| 1560 | r = 1; |
| 1561 | } |
| 1562 | else { |
| 1563 | if(rcmp < 0) { |
| 1564 | max = (max-half); |
| 1565 | } |
| 1566 | else { |
| 1567 | min = (min+half); |
| 1568 | } |
| 1569 | current = min; |
| 1570 | } |
| 1571 | } |
| 1572 | return r; |
| 1573 | } |
| 1574 | |
| 1575 | void *thread_process_bsgs(void *vargp) { |
| 1576 | |