add iarray
This commit is contained in:
16
array/iarray_init.c
Normal file
16
array/iarray_init.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "iarray.h"
|
||||
|
||||
void iarray_init(iarray* ia,size_t elemsize) {
|
||||
ia->elemsize=elemsize;
|
||||
ia->pages=0;
|
||||
ia->pagefence=0;
|
||||
if (elemsize<1024)
|
||||
ia->bytesperpage=4096;
|
||||
else if (elemsize<8192)
|
||||
ia->bytesperpage=65536;
|
||||
else
|
||||
ia->bytesperpage=elemsize;
|
||||
ia->elemperpage=ia->bytesperpage/elemsize;
|
||||
pthread_mutex_init(&ia->m,NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user