ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/utils.C
(Generate patch)

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.107 by root, Sat Nov 17 23:33:17 2018 UTC vs.
Revision 1.110 by root, Sat Oct 8 21:54:05 2022 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 6 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 7 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 8 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 9 * Free Software Foundation, either version 3 of the License, or (at your
113 114
114 LOG (llevError, "fork abort: %s\n", msg); 115 LOG (llevError, "fork abort: %s\n", msg);
115} 116}
116 117
117void * 118void *
118salloc_ (int n) 119salloc_ (int n) noexcept
119{ 120{
120 void *ptr = g_slice_alloc (n); 121 void *ptr = g_slice_alloc (n);
121 122
122 if (!ptr) 123 if (ecb_expect_false (!ptr))
123 throw std::bad_alloc (); 124 {
125 LOG (llevError, "out of memory allocating %d bytes, aborting.\n", n);
126 abort ();
127 }
124 128
125 slice_alloc += n; 129 slice_alloc += n;
126 return ptr; 130 return ptr;
127} 131}
128 132
133// thos noinline works around a bug in gcc10, which otherwise inlines
134// this fucntion and, only in the inlined versions, optimises out
135// the memset, leasving memory uninitialised.
136ecb_noinline
129void * 137void *
130salloc_ (int n, void *src) 138salloc_ (int n, void *src) noexcept
131{ 139{
132 void *ptr = salloc_ (n); 140 void *ptr = salloc_ (n);
133 141
134 if (src) 142 if (src)
135 memcpy (ptr, src, n); 143 memcpy (ptr, src, n);
162 170
163void 171void
164g_slice_free1 (unsigned long size, void *ptr) 172g_slice_free1 (unsigned long size, void *ptr)
165{ 173{
166 //fprintf (stderr, "g_slice_free %ld %p\n", size, ptr);//D 174 //fprintf (stderr, "g_slice_free %ld %p\n", size, ptr);//D
167 if (expect_true (ptr)) 175 if (ecb_expect_true (ptr))
168 { 176 {
169 unsigned long *p = (unsigned long *)ptr; 177 unsigned long *p = (unsigned long *)ptr;
170 unsigned long s = *--p ^ MAGIC; 178 unsigned long s = *--p ^ MAGIC;
171 179
172 if (size != (unsigned long)(*p ^ MAGIC)) 180 if (size != (unsigned long)(*p ^ MAGIC))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines