document the return value expected from the callback given to iob_write

remove unused #include in iob_reset
if iob_addfile_close fails, it now closes the fd
if iob_addbuf_munmap fails, it now munmaps the buf
if iob_addbuf_free fails, it now frees the buf
some win32 cross-compile fixes for iarray
This commit is contained in:
leitner
2012-02-24 02:00:52 +00:00
parent 4f1e1d300c
commit c2a2a15c12
7 changed files with 36 additions and 6 deletions

View File

@@ -9,7 +9,11 @@ void* iarray_allocate(iarray* ia,size_t pos) {
return ia->pages[y]+(pos%ia->elemperpage)*ia->elemsize;
/* the case where ia->pages == NULL is implicit */
#ifdef __MINGW32__
EnterCriticalSection(&ia->cs);
#else
pthread_mutex_lock(&ia->m);
#endif
if (__unlikely(y >= ia->pagefence)) {
char** np;
@@ -37,11 +41,19 @@ void* iarray_allocate(iarray* ia,size_t pos) {
* however */
if (__unlikely(ia->pages[y]==0 && (ia->pages[y]=malloc(ia->bytesperpage))==0)) {
unlockandfail:
#ifdef __MINGW32__
LeaveCriticalSection(&ia->cs);
#else
pthread_mutex_unlock(&ia->m);
#endif
return 0;
}
#ifdef __MINGW32__
LeaveCriticalSection(&ia->cs);
#else
pthread_mutex_unlock(&ia->m);
#endif
return ia->pages[y] + (pos%ia->elemperpage)*ia->elemsize;
}