void *smalloc(size_t size) { unsigned int i, end_pool; if (size != (unsigned int) size) return NULL; i = last_pool; end_pool = nr_pools; do { for (; i < end_pool; i++) { void *ptr = smalloc_pool(&mp[i], size); if (ptr) { last_pool = i; return ptr; } } if (last_pool) { end_pool = last_pool; last_pool = i = 0; continue; } break; } while (1); return NULL; }
void *smalloc(size_t size) { unsigned int i, end_pool; if (size != (unsigned int) size) return NULL; i = last_pool; end_pool = nr_pools; do { for (; i < end_pool; i++) { void *ptr = smalloc_pool(&mp[i], size); if (ptr) { last_pool = i; return ptr; } } if (last_pool) { end_pool = last_pool; last_pool = i = 0; continue; } break; } while (1); log_err("smalloc: OOM. Consider using --alloc-size to increase the " "shared memory available.\n"); return NULL; }
void *smalloc(size_t size) { unsigned int i; if (size != (unsigned int) size) return NULL; global_write_lock(); i = last_pool; do { for (; i < nr_pools; i++) { void *ptr = smalloc_pool(&mp[i], size); if (ptr) { last_pool = i; global_write_unlock(); return ptr; } } if (last_pool) { last_pool = 0; continue; } if (nr_pools + 1 > MAX_POOLS) break; else { i = nr_pools; if (add_pool(&mp[nr_pools], size)) goto out; } } while (1); out: global_write_unlock(); return NULL; }