ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.124 by root, Fri Nov 18 20:20:05 2016 UTC vs.
Revision 1.125 by root, Wed Nov 14 22:52:13 2018 UTC

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
302extern ssize_t slice_alloc; // statistics 302extern ssize_t slice_alloc; // statistics
303 303
304void *salloc_ (int n) throw (std::bad_alloc); 304void *salloc_ (int n);
305void *salloc_ (int n, void *src) throw (std::bad_alloc); 305void *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
308template<typename T> 308template<typename T>
309inline T *salloc (int n = 1) throw (std::bad_alloc) { return (T *)salloc_ (n * sizeof (T)); } 309inline 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
313template<typename T> 313template<typename T>
314inline T *salloc (int n, T *src) throw (std::bad_alloc) { return (T *)salloc_ (n * sizeof (T), (void *)src); } 314inline T *salloc (int n, T *src) { return (T *)salloc_ (n * sizeof (T), (void *)src); }
315 315
316// clears the memory 316// clears the memory
317template<typename T> 317template<typename T>
318inline T *salloc0(int n = 1) throw (std::bad_alloc) { return (T *)salloc_ (n * sizeof (T), 0); } 318inline T *salloc0(int n = 1) { return (T *)salloc_ (n * sizeof (T), 0); }
319 319
320// for symmetry 320// for symmetry
321template<typename T> 321template<typename T>
322inline void sfree (T *ptr, int n = 1) throw () 322inline 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
333template<typename T> 333template<typename T>
334inline void sfree0 (T *&ptr, int n = 1) throw () 334inline 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)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines