… | |
… | |
299 | for (uint32_t idxvar, mask_ = mask; \ |
299 | for (uint32_t idxvar, mask_ = mask; \ |
300 | mask_ && ((idxvar = least_significant_bit (mask_)), mask_ &= ~(1 << idxvar), 1);) |
300 | mask_ && ((idxvar = least_significant_bit (mask_)), mask_ &= ~(1 << idxvar), 1);) |
301 | |
301 | |
302 | extern ssize_t slice_alloc; // statistics |
302 | extern ssize_t slice_alloc; // statistics |
303 | |
303 | |
304 | void *salloc_ (int n) throw (std::bad_alloc); |
304 | void *salloc_ (int n); |
305 | void *salloc_ (int n, void *src) throw (std::bad_alloc); |
305 | void *salloc_ (int n, void *src); |
306 | |
306 | |
307 | // strictly the same as g_slice_alloc, but never returns 0 |
307 | // strictly the same as g_slice_alloc, but never returns 0 |
308 | template<typename T> |
308 | template<typename T> |
309 | inline T *salloc (int n = 1) throw (std::bad_alloc) { return (T *)salloc_ (n * sizeof (T)); } |
309 | inline T *salloc (int n = 1) { return (T *)salloc_ (n * sizeof (T)); } |
310 | |
310 | |
311 | // also copies src into the new area, like "memdup" |
311 | // also copies src into the new area, like "memdup" |
312 | // if src is 0, clears the memory |
312 | // if src is 0, clears the memory |
313 | template<typename T> |
313 | template<typename T> |
314 | inline T *salloc (int n, T *src) throw (std::bad_alloc) { return (T *)salloc_ (n * sizeof (T), (void *)src); } |
314 | inline T *salloc (int n, T *src) { return (T *)salloc_ (n * sizeof (T), (void *)src); } |
315 | |
315 | |
316 | // clears the memory |
316 | // clears the memory |
317 | template<typename T> |
317 | template<typename T> |
318 | inline T *salloc0(int n = 1) throw (std::bad_alloc) { return (T *)salloc_ (n * sizeof (T), 0); } |
318 | inline T *salloc0(int n = 1) { return (T *)salloc_ (n * sizeof (T), 0); } |
319 | |
319 | |
320 | // for symmetry |
320 | // for symmetry |
321 | template<typename T> |
321 | template<typename T> |
322 | inline void sfree (T *ptr, int n = 1) throw () |
322 | inline void sfree (T *ptr, int n = 1) noexcept |
323 | { |
323 | { |
324 | if (expect_true (ptr)) |
324 | if (expect_true (ptr)) |
325 | { |
325 | { |
326 | slice_alloc -= n * sizeof (T); |
326 | slice_alloc -= n * sizeof (T); |
327 | if (DEBUG_POISON) memset (ptr, DEBUG_POISON, n * sizeof (T)); |
327 | if (DEBUG_POISON) memset (ptr, DEBUG_POISON, n * sizeof (T)); |
… | |
… | |
329 | } |
329 | } |
330 | } |
330 | } |
331 | |
331 | |
332 | // nulls the pointer |
332 | // nulls the pointer |
333 | template<typename T> |
333 | template<typename T> |
334 | inline void sfree0 (T *&ptr, int n = 1) throw () |
334 | inline void sfree0 (T *&ptr, int n = 1) noexcept |
335 | { |
335 | { |
336 | sfree<T> (ptr, n); |
336 | sfree<T> (ptr, n); |
337 | ptr = 0; |
337 | ptr = 0; |
338 | } |
338 | } |
339 | |
339 | |
… | |
… | |
413 | struct rebind |
413 | struct rebind |
414 | { |
414 | { |
415 | typedef slice_allocator<U> other; |
415 | typedef slice_allocator<U> other; |
416 | }; |
416 | }; |
417 | |
417 | |
418 | slice_allocator () throw () { } |
418 | slice_allocator () noexcept { } |
419 | slice_allocator (const slice_allocator &) throw () { } |
419 | slice_allocator (const slice_allocator &) noexcept { } |
420 | template<typename Tp2> |
420 | template<typename Tp2> |
421 | slice_allocator (const slice_allocator<Tp2> &) throw () { } |
421 | slice_allocator (const slice_allocator<Tp2> &) noexcept { } |
422 | |
422 | |
423 | ~slice_allocator () { } |
423 | ~slice_allocator () { } |
424 | |
424 | |
425 | pointer address (reference x) const { return &x; } |
425 | pointer address (reference x) const { return &x; } |
426 | const_pointer address (const_reference x) const { return &x; } |
426 | const_pointer address (const_reference x) const { return &x; } |
… | |
… | |
433 | void deallocate (pointer p, size_type n) |
433 | void deallocate (pointer p, size_type n) |
434 | { |
434 | { |
435 | sfree<Tp> (p, n); |
435 | sfree<Tp> (p, n); |
436 | } |
436 | } |
437 | |
437 | |
438 | size_type max_size () const throw () |
438 | size_type max_size () const noexcept |
439 | { |
439 | { |
440 | return size_t (-1) / sizeof (Tp); |
440 | return size_t (-1) / sizeof (Tp); |
441 | } |
441 | } |
442 | |
442 | |
443 | void construct (pointer p, const Tp &val) |
443 | void construct (pointer p, const Tp &val) |