[BACK]Return to apprentice.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Diff for /src/usr.bin/file/Attic/apprentice.c between version 1.30 and 1.31

version 1.30, 2014/01/16 21:45:33 version 1.31, 2014/05/18 17:50:11
Line 629 
Line 629 
   
         maxmagic = MAXMAGIS;          maxmagic = MAXMAGIS;
         if ((marray = calloc(maxmagic, sizeof(*marray))) == NULL) {          if ((marray = calloc(maxmagic, sizeof(*marray))) == NULL) {
                 file_oomem(ms, maxmagic * sizeof(*marray));                  file_oomem2(ms, maxmagic, sizeof(*marray));
                 return -1;                  return -1;
         }          }
         marraycount = 0;          marraycount = 0;
Line 714 
Line 714 
         for (i = 0; i < marraycount; i++)          for (i = 0; i < marraycount; i++)
                 mentrycount += marray[i].cont_count;                  mentrycount += marray[i].cont_count;
   
         if ((*magicp = malloc(sizeof(**magicp) * mentrycount)) == NULL) {          if ((*magicp = reallocarray(NULL, mentrycount, sizeof(**magicp))) == NULL) {
                 file_oomem(ms, sizeof(**magicp) * mentrycount);                  file_oomem2(ms, mentrycount, sizeof(**magicp));
                 errs++;                  errs++;
                 goto out;                  goto out;
         }          }
Line 1003 
Line 1003 
                 if (me->cont_count == me->max_count) {                  if (me->cont_count == me->max_count) {
                         struct magic *nm;                          struct magic *nm;
                         size_t cnt = me->max_count + ALLOC_CHUNK;                          size_t cnt = me->max_count + ALLOC_CHUNK;
                         if ((nm = realloc(me->mp, sizeof(*nm) * cnt)) == NULL) {                          if ((nm = reallocarray(me->mp, cnt, sizeof(*nm)))
                                 file_oomem(ms, sizeof(*nm) * cnt);                              == NULL) {
                                   file_oomem2(ms, cnt, sizeof(*nm));
                                 return -1;                                  return -1;
                         }                          }
                         me->mp = m = nm;                          me->mp = m = nm;
Line 1018 
Line 1019 
                         struct magic_entry *mp;                          struct magic_entry *mp;
   
                         maxmagic += ALLOC_INCR;                          maxmagic += ALLOC_INCR;
                         if ((mp = realloc(*mentryp, sizeof(*mp) * maxmagic)) ==                          if ((mp = reallocarray(*mentryp, maxmagic,
                             NULL) {                              sizeof(*mp))) == NULL) {
                                 file_oomem(ms, sizeof(*mp) * maxmagic);                                  file_oomem2(ms, maxmagic, sizeof(*mp));
                                 return -1;                                  return -1;
                         }                          }
                         (void)memset(&mp[*nmentryp], 0, sizeof(*mp) *                          (void)memset(&mp[*nmentryp], 0, sizeof(*mp) *
Line 1029 
Line 1030 
                 }                  }
                 me = &(*mentryp)[*nmentryp];                  me = &(*mentryp)[*nmentryp];
                 if (me->mp == NULL) {                  if (me->mp == NULL) {
                         if ((m = malloc(sizeof(*m) * ALLOC_CHUNK)) == NULL) {                          if ((m = reallocarray(NULL, ALLOC_CHUNK, sizeof(*m))) == NULL) {
                                 file_oomem(ms, sizeof(*m) * ALLOC_CHUNK);                                  file_oomem2(ms, ALLOC_CHUNK, sizeof(*m));
                                 return -1;                                  return -1;
                         }                          }
                         me->mp = m;                          me->mp = m;

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31