1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 // "Hello BDelta!"
5
6 #include "bdelta.h"
7 #include <string.h>
8 #include <stdio.h>
9
10 const int smallestMatch = 8;
11 char *a = "abcdefghijklmnopqrstuvwxyz", *b = "abcdefghijklmnopqrstuvwxyz";
a_read(unsigned place,unsigned num)12 void *a_read(unsigned place, unsigned num) {
13 return (char*)(a + place);
14 }
15
b_read(unsigned place,unsigned num)16 void *b_read(unsigned place, unsigned num) {
17 return (char*)(b + place);
18 }
main()19 main() {
20 void *bi = bdelta_init_alg(strlen(a), strlen(b), a_read, b_read);
21 int nummatches;
22 for (int i = 64; i >= smallestMatch; i/=2)
23 nummatches = bdelta_pass(bi, i);
24 for (int i = 0; i < nummatches; ++i) {
25 unsigned p1, p2, num;
26 bdelta_getMatch(bi, i, &p1, &p2, &num);
27 printf("Got match\n");
28 }
29
30 }
31
32