Changeset bb2c60d


Ignore:
Timestamp:
Mar 5, 2007, 9:00:24 PM (18 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d08162a
Parents:
2058d7a
Message:
perlwrap.pm: getting rid of one more mainloop_hook error message.
zephyr.c: reworking zephyr subscription process (again).
  * Sub all at once if possible.
  * Don't sub to zpunt lines.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perlwrap.pm

    r39dc159 rbb2c60d  
    502502    # use $shutdown to tell modules that that's what we're doing.
    503503    $BarnOwl::shutdown = 1;
    504     BarnOwl::mainloop_hook();
     504    BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
    505505
    506506    BarnOwl::shutdown() if *BarnOwl::shutdown{CODE};
  • zephyr.c

    rf6050ee rbb2c60d  
    8888    owl_free(subs[i].zsub_recipient);
    8989  }
     90
    9091  return ret;
    9192}
     
    106107  char *tmp, *start;
    107108  char buffer[1024], subsfile[1024];
    108   ZSubscription_t subs[3001];
     109  ZSubscription_t *subs;
     110  int subSize = 1024;
    109111  int count, ret;
    110112  struct stat statbuff;
    111113
     114  subs = owl_malloc(sizeof(ZSubscription_t) * subSize);
    112115  if (filename==NULL) {
    113116    sprintf(subsfile, "%s/%s", owl_global_get_homedir(&g), ".zephyr.subs");
     
    135138    }
    136139   
    137     if (count >= 3000) {
    138       ret = owl_zephyr_loadsubs_helper(subs, count);
    139       if (ret != 0) {
    140         fclose(file);
    141         return(ret);
     140    if (count >= subSize) {
     141      ZSubscription_t* newsubs;
     142      newsubs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize * 2);
     143      if (NULL == newsubs) {
     144        /* If realloc fails, load what we've got, clear, and continue */
     145        ret = owl_zephyr_loadsubs_helper(subs, count);
     146        if (ret != 0) {
     147          fclose(file);
     148          return(ret);
     149        }
     150        count=0;
    142151      }
    143       count=0;
     152      else {
     153        subs = newsubs;
     154        subSize *= 2;
     155      }
    144156    }
    145157   
     
    152164    subs[count].zsub_recipient=owl_strdup(tmp);
    153165   
    154     /* if it started with '-' then add it to the global punt list */
     166    /* if it started with '-' then add it to the global punt list, and
     167     * remove it from the list of subs. */
    155168    if (buffer[0]=='-') {
    156169      owl_function_zpunt(subs[count].zsub_class, subs[count].zsub_classinst, subs[count].zsub_recipient, 0);
    157     }
    158    
    159     count++;
     170      owl_free(subs[count].zsub_class);
     171      owl_free(subs[count].zsub_classinst);
     172      owl_free(subs[count].zsub_recipient);
     173    }
     174    else {
     175      count++;
     176    }
    160177  }
    161178  fclose(file);
    162179
    163180  ret=owl_zephyr_loadsubs_helper(subs, count);
    164 
     181  owl_free(subs);
    165182  return(ret);
    166183#else
Note: See TracChangeset for help on using the changeset viewer.