diff --git a/bsdiff.c b/bsdiff.c index 628f1c1..0165b0e 100644 --- a/bsdiff.c +++ b/bsdiff.c @@ -321,24 +321,24 @@ static int bsdiff_internal(const struct bsdiff_request req) return 0; } -int bsdiff(const uint8_t* old, int64_t oldsize, const uint8_t* new, int64_t newsize, struct bsdiff_stream* stream) +int bsdiff(const uint8_t* source, int64_t sourcesize, const uint8_t* target, int64_t targetsize, struct bsdiff_stream* stream) { int result; struct bsdiff_request req; - if((req.I=stream->malloc((oldsize+1)*sizeof(int64_t)))==NULL) + if((req.I=stream->malloc((sourcesize+1)*sizeof(int64_t)))==NULL) return -1; - if((req.buffer=stream->malloc(newsize+1))==NULL) + if((req.buffer=stream->malloc(targetsize+1))==NULL) { stream->free(req.I); return -1; } - req.old = old; - req.oldsize = oldsize; - req.new = new; - req.newsize = newsize; + req.old = source; + req.oldsize = sourcesize; + req.new = target; + req.newsize = targetsize; req.stream = stream; result = bsdiff_internal(req); diff --git a/bsdiff.h b/bsdiff.h index b37da5f..1fcd683 100644 --- a/bsdiff.h +++ b/bsdiff.h @@ -31,6 +31,10 @@ # include # include +#ifdef __cplusplus +extern "C" { +#endif + struct bsdiff_stream { void* opaque; @@ -40,6 +44,10 @@ struct bsdiff_stream int (*write)(struct bsdiff_stream* stream, const void* buffer, int size); }; -int bsdiff(const uint8_t* old, int64_t oldsize, const uint8_t* new, int64_t newsize, struct bsdiff_stream* stream); +int bsdiff(const uint8_t* source, int64_t sourcesize, const uint8_t* target, int64_t targetsize, struct bsdiff_stream* stream); + +#ifdef __cplusplus +} +#endif #endif diff --git a/bspatch.c b/bspatch.c index b544914..28830e1 100644 --- a/bspatch.c +++ b/bspatch.c @@ -45,7 +45,7 @@ static int64_t offtin(uint8_t *buf) return y; } -int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, struct bspatch_stream* stream) +int bspatch(const uint8_t* source, int64_t sourcesize, uint8_t* target, int64_t targetsize, struct bspatch_stream* stream) { uint8_t buf[8]; int64_t oldpos,newpos; @@ -53,7 +53,7 @@ int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, int64_t i; oldpos=0;newpos=0; - while(newposread(stream, buf, 8)) @@ -62,28 +62,28 @@ int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, }; /* Sanity-check */ - if(newpos+ctrl[0]>newsize) + if(newpos+ctrl[0]>targetsize) return -1; /* Read diff string */ - if (stream->read(stream, new + newpos, ctrl[0])) + if (stream->read(stream, target + newpos, ctrl[0])) return -1; /* Add old data to diff string */ for(i=0;i=0) && (oldpos+i=0) && (oldpos+inewsize) + if(newpos+ctrl[1]>targetsize) return -1; /* Read extra string */ - if (stream->read(stream, new + newpos, ctrl[1])) + if (stream->read(stream, target + newpos, ctrl[1])) return -1; /* Adjust pointers */ diff --git a/bspatch.h b/bspatch.h index 099c36e..e713de7 100644 --- a/bspatch.h +++ b/bspatch.h @@ -30,13 +30,21 @@ # include +#ifdef __cplusplus +extern "C" { +#endif + struct bspatch_stream { void* opaque; int (*read)(const struct bspatch_stream* stream, void* buffer, int length); }; -int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, struct bspatch_stream* stream); +int bspatch(const uint8_t* source, int64_t sourcesize, uint8_t* target, int64_t targetsize, struct bspatch_stream* stream); + +#ifdef __cplusplus +} +#endif #endif