Diff for /libaitsync/src/aitsync.c between versions 1.3.2.3 and 1.5.2.1

version 1.3.2.3, 2012/11/13 13:19:15 version 1.5.2.1, 2014/02/04 16:39:00
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012Copyright 2004 - 2014
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 65  func_comp(sync_tag_t const *t1, sync_tag_t const *t2) Line 65  func_comp(sync_tag_t const *t1, sync_tag_t const *t2)
  */   */
   
 // sync_GetErrno() Get error code of last operation  // sync_GetErrno() Get error code of last operation
inline intint
 sync_GetErrno()  sync_GetErrno()
 {  {
         return sync_Errno;          return sync_Errno;
 }  }
   
 // sync_GetError() Get error text of last operation  // sync_GetError() Get error text of last operation
inline const char *const char *
 sync_GetError()  sync_GetError()
 {  {
         return sync_Error;          return sync_Error;
 }  }
   
 // sync_SetErr() Set error to variables for internal use!!!  // sync_SetErr() Set error to variables for internal use!!!
inline voidvoid
 sync_SetErr(int eno, char *estr, ...)  sync_SetErr(int eno, char *estr, ...)
 {  {
         va_list lst;          va_list lst;
   
         sync_Errno = eno;          sync_Errno = eno;
        memset(sync_Error, 0, STRSIZ);        memset(sync_Error, 0, sizeof sync_Error);
         va_start(lst, estr);          va_start(lst, estr);
        vsnprintf(sync_Error, STRSIZ, estr, lst);        vsnprintf(sync_Error, sizeof sync_Error, estr, lst);
         va_end(lst);          va_end(lst);
 }  }
   
Line 116  syncSignature(const char *csInput, const char *csSig,  Line 116  syncSignature(const char *csInput, const char *csSig, 
         if (inf == -1)          if (inf == -1)
                 return inf;                  return inf;
         if (compress & 2)          if (compress & 2)
                f = sync_Temp(szTemp, MAXPATHLEN);                f = sync_Temp(szTemp, sizeof szTemp);
         else          else
                 f = sync_Open(csSig, O_WRONLY, 0);                  f = sync_Open(csSig, O_WRONLY, 0);
         if (f == -1) {          if (f == -1) {
Line 195  syncDelta(const char *csInput, const char *csSig, cons Line 195  syncDelta(const char *csInput, const char *csSig, cons
                 f = sync_Open(csSig, O_RDONLY, 0);                  f = sync_Open(csSig, O_RDONLY, 0);
                 if (-1 == f)                  if (-1 == f)
                         return f;                          return f;
                sigf = sync_Temp(szTemp, MAXPATHLEN);                sigf = sync_Temp(szTemp, sizeof szTemp);
                 if (-1 == sigf) {                  if (-1 == sigf) {
                         sync_Close(f);                          sync_Close(f);
                         return sigf;                          return sigf;
Line 257  syncDelta(const char *csInput, const char *csSig, cons Line 257  syncDelta(const char *csInput, const char *csSig, cons
                 tags[i] = NULL_TAG;                  tags[i] = NULL_TAG;
   
         /* build second index from signature blocks */          /* build second index from signature blocks */
        tag_table = (sync_tag_t*) calloc(cnt, sizeof(sync_tag_t));        tag_table = (sync_tag_t*) e_calloc(cnt, sizeof(sync_tag_t));
         if (!tag_table) {          if (!tag_table) {
                 LOGERR;                  LOGERR;
                 munmap(chunks, sb.st_size);                  munmap(chunks, sb.st_size);
Line 281  syncDelta(const char *csInput, const char *csSig, cons Line 281  syncDelta(const char *csInput, const char *csSig, cons
   
         inf = sync_Open(csInput, O_RDONLY, 0);          inf = sync_Open(csInput, O_RDONLY, 0);
         if (inf == -1) {          if (inf == -1) {
                free(tag_table);                e_free(tag_table);
                 munmap(chunks, sb.st_size);                  munmap(chunks, sb.st_size);
                 return inf;                  return inf;
         }          }
         if (compress & 1)          if (compress & 1)
                f = sync_Temp(szTemp, MAXPATHLEN);                f = sync_Temp(szTemp, sizeof szTemp);
         else          else
                 f = sync_Open(csDelta, O_WRONLY, 0);                  f = sync_Open(csDelta, O_WRONLY, 0);
         if (f == -1) {          if (f == -1) {
                 sync_Close(inf);                  sync_Close(inf);
                free(tag_table);                e_free(tag_table);
                 munmap(chunks, sb.st_size);                  munmap(chunks, sb.st_size);
                 return f;                  return f;
         }          }
Line 425  end: Line 425  end:
         if (compress & 1)          if (compress & 1)
                 unlink(szTemp);                  unlink(szTemp);
         sync_Close(inf);          sync_Close(inf);
        free(tag_table);        e_free(tag_table);
         munmap(chunks, sb.st_size);          munmap(chunks, sb.st_size);
         return ret;          return ret;
 }  }
Line 456  syncPatch(const char *csInput, const char *csDelta, co Line 456  syncPatch(const char *csInput, const char *csDelta, co
                 f = sync_Open(csDelta, O_RDONLY, 0);                  f = sync_Open(csDelta, O_RDONLY, 0);
                 if (f == -1)                  if (f == -1)
                         return f;                          return f;
                d = sync_Temp(szTemp, MAXPATHLEN);                d = sync_Temp(szTemp, sizeof szTemp);
                 if (d == -1) {                  if (d == -1) {
                         sync_Close(f);                          sync_Close(f);
                         return d;                          return d;
Line 503  syncPatch(const char *csInput, const char *csDelta, co Line 503  syncPatch(const char *csInput, const char *csDelta, co
   
         inf = sync_Open(csInput, O_RDONLY, 0);          inf = sync_Open(csInput, O_RDONLY, 0);
         if (inf == -1) {          if (inf == -1) {
                if (pieces)                e_free(pieces);
                        free(pieces); 
                 munmap(delta, sb.st_size);                  munmap(delta, sb.st_size);
                 return inf;                  return inf;
         }          }
         outf = sync_Open(csPatch, O_WRONLY, 0);          outf = sync_Open(csPatch, O_WRONLY, 0);
         if (outf == -1) {          if (outf == -1) {
                 sync_Close(inf);                  sync_Close(inf);
                if (pieces)                e_free(pieces);
                        free(pieces); 
                 munmap(delta, sb.st_size);                  munmap(delta, sb.st_size);
                 return outf;                  return outf;
         }          }
Line 616  syncPatch(const char *csInput, const char *csDelta, co Line 614  syncPatch(const char *csInput, const char *csDelta, co
 end:  end:
         sync_Close(inf);          sync_Close(inf);
         sync_Close(outf);          sync_Close(outf);
        if (pieces)        e_free(pieces);
                free(pieces); 
         munmap(delta, sb.st_size);          munmap(delta, sb.st_size);
         return ret;          return ret;
 }  }

Removed from v.1.3.2.3  
changed lines
  Added in v.1.5.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>