"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/bytesearch.cpp" between
bed-3.0.3.src.tar.xz and bed-3.1.0.src.tar.xz

About: bed is an adjustable data format binary editor.

bytesearch.cpp  (bed-3.0.3.src.tar.xz):bytesearch.cpp  (bed-3.1.0.src.tar.xz)
skipping to change at line 17 skipping to change at line 17
#include <stdint.h> #include <stdint.h>
#include <limits.h> #include <limits.h>
#include <unistd.h> #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#include "editor.h" #include "editor.h"
#include "system.h" #include "system.h"
#include "myalloc.h" #include "myalloc.h"
#include "main.h" #include "main.h"
#ifdef USE_MMAP #ifdef USE_MMAP
const long mmap_page_size = (long) sysconf (_SC_PAGESIZE); const long mmap_page_size = (long) sysconf (_SC_PAGESIZE);
#define FREEMMAP(str, len) {if(nommap){free(str);}else {MUNMAP(str,len);} } #define FREEMMAP(str, len) {if(nommap){ databuffree(str);}else {MUNMAP(st r,len);}}
#define BIGGERMMAPBLOCK #define BIGGERMMAPBLOCK
#endif #endif
#if defined(USE_MMAP)&&!defined(BIGGERMMAPBLOCK) #if defined(USE_MMAP)&&!defined(BIGGERMMAPBLOCK)
int STBLOCKSIZE=mmap_page_size; int STBLOCKSIZE=mmap_page_size;
#else #else
//int STBLOCKSIZE=4096; //int STBLOCKSIZE=4096;
#ifdef _WIN32 #ifdef _WIN32
int STBLOCKSIZE=2048; int STBLOCKSIZE=2048;
#else #else
skipping to change at line 52 skipping to change at line 52
*/ */
BEDS_SIZE_T Memory::mmapgetblock(MMAPBLOCKTYPE blocknr,char *buf) { BEDS_SIZE_T Memory::mmapgetblock(MMAPBLOCKTYPE blocknr,char *buf) {
BEDS_SIZE_T takesize,disktakesize; BEDS_SIZE_T takesize,disktakesize;
OFFTYPE offset=(blocknr*MMAPBLOCKSIZE); OFFTYPE offset=(blocknr*MMAPBLOCKSIZE);
if(offset>=filesize) if(offset>=filesize)
return 0; return 0;
caddr_t ptr; caddr_t ptr;
takesize=minnum(MMAPBLOCKSIZE,filesize-offset); takesize=minnum(MMAPBLOCKSIZE,filesize-offset);
disktakesize=minnum(MMAPBLOCKSIZE,diskfilesize-offset); disktakesize=minnum(MMAPBLOCKSIZE,useddiskfilesize-offset);
if(mmapfailed||(disktakesize>0&&((ptr=(caddr_t)MMAP(buf, disktakesize , P ROT_READ|PROT_WRITE , MAP_PRIVATE|MAP_FIXED , filehandle, offset))== MAP_FAILED ))) { if(mmapfailed||(disktakesize>0&&((ptr=(caddr_t)MMAP(buf, disktakesize , P ROT_READ|PROT_WRITE , MAP_PRIVATE|MAP_FIXED , filehandle, offset))== MAP_FAILED ))) {
mmapfailed=1; mmapfailed=1;
int len=MMAPBLOCKSIZE/ BLOCKSIZE; int len=MMAPBLOCKSIZE/ BLOCKSIZE;
BLOCKTYPE start=blocknr*len; BLOCKTYPE start=blocknr*len;
takesize=0; takesize=0;
for(int iter=0;iter<len;iter++) { for(int iter=0;iter<len;iter++) {
takesize+=getblock(iter+start, buf+(BLOCKSIZE*iter)); takesize+=getblock(iter+start, buf+(BLOCKSIZE*iter));
} }
return takesize; return takesize;
} }
skipping to change at line 101 skipping to change at line 101
#ifndef BIGGERMMAPBLOCK #ifndef BIGGERMMAPBLOCK
#define TAKEBLOCKS 3 #define TAKEBLOCKS 3
#else #else
#define TAKEBLOCKS 2 #define TAKEBLOCKS 2
#endif #endif
#include "misc.h" #include "misc.h"
#define ablock(blo) buf+blocksize()*(blo) #define ablock(blo) buf+blocksize()*(blo)
#define EXTRAMMAP 0 #define EXTRAMMAP 0
#define databuffree(x) free(x) #define databuffree(x) alignedfree(x)
#define databufalloc(size) (char *)alignedalloc(blocksize(), size) #define databufalloc(size) (char *)alignedalloc(blocksize(), size)
//#if defined(_WIN32) && !defined(USETHREADS) //#if defined(_WIN32) && !defined(USETHREADS)
#undef MEMORY #undef MEMORY
#define MEMORY #define MEMORY
#include "searchinterrupt.h" #include "searchinterrupt.h"
inline int nochange(const int ch) {return ch;}; inline int nochange(const int ch) {return ch;};
//strncasecmp,(const char *, const char *, size_t)); //strncasecmp,(const char *, const char *, size_t));
inline int iunequal(const void *onev,const void *twov,size_t len) { inline int iunequal(const void *onev,const void *twov,size_t len) {
return unequal<mklow>(onev,twov,len); return unequal<mklow>(onev,twov,len);
skipping to change at line 176 skipping to change at line 176
start+=(searchlen-bij); start+=(searchlen-bij);
} }
else else
start+=searchlen; start+=searchlen;
} }
for(searchpos=(ending-(endstart-start));searchpos<endblock;) { for(searchpos=(ending-(endstart-start));searchpos<endblock;) {
if(table[buf[(searchpos+endstr)%(DBUFSIZE)]]) { if(table[buf[(searchpos+endstr)%(DBUFSIZE)]]) {
if((bij=table[buf[(searchpos+endstr)%(DBU FSIZE)]])==searchlen) { if((bij=table[buf[(searchpos+endstr)%(DBU FSIZE)]])==searchlen) {
for(i=0;searchstr[i]==givelow(buf [(searchpos+i)%(DBUFSIZE)]);i++) for(i=0;(unsigned char)searchstr[ i]==(unsigned char)givelow(buf[(searchpos+i)%(DBUFSIZE)]);i++)
if(i==endstr) { if(i==endstr) {
if(Stype. List) if(Stype. List)
a ddmark(searchpos, searchlen); a ddmark(searchpos, searchlen);
else { else {
F REEMMAP(buf, TAKEBLOCKS*MMAPBLOCKSIZE); F REEMMAP(buf, TAKEBLOCKS*MMAPBLOCKSIZE);
r eturn searchpos++; r eturn searchpos++;
} }
} }
searchpos++; searchpos++;
} }
 End of changes. 4 change blocks. 
4 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)