Changeset 34989

Show
Ignore:
Timestamp:
08/23/09 21:30:26 (4 years ago)
Author:
kazuho
Message:

return more errors

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/c/picoev/trunk/picoev.h

    r34988 r34989  
    1717#define PICOEV_IS_INITED (picoev.max_fd != 0)   
    1818#define PICOEV_IS_INITED_AND_FD_IN_RANGE(fd) ((fd) < picoev.max_fd) 
    19 #define PICOEV_NO_MEMORY(p) ((p) != NULL) 
    2019#define PICOEV_TOO_MANY_LOOPS (picoev.num_loops != 0) /* use after ++ */ 
    2120#define PICOEV_FD_BELONGS_TO_LOOP(loop, fd) \ 
     
    7978  /* initializes picoev */ 
    8079  PICOEV_INLINE 
    81   void picoev_init(int max_fd) { 
     80  int picoev_init(int max_fd) { 
    8281    assert(! PICOEV_IS_INITED); 
    8382    assert(max_fd > 0); 
    84     picoev.fds = (picoev_fd*)valloc(sizeof(picoev_fd) * max_fd); 
    85     assert(PICOEV_NO_MEMORY(picoev.fds)); 
     83    if ((picoev.fds = (picoev_fd*)valloc(sizeof(picoev_fd) * max_fd)) == NULL) { 
     84      return -1; 
     85    } 
    8686    picoev.max_fd = max_fd; 
    8787    picoev.num_loops = 0; 
     
    9191      = PICOEV_RND_UP(picoev.timeout_vec_size, PICOEV_SIMD_BITS) 
    9292      / PICOEV_LONG_BITS; 
     93    return 0; 
    9394  } 
    9495