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.100 by root, Tue Jan 3 11:25:31 2012 UTC vs.
Revision 1.102 by root, Sun Nov 11 01:27:44 2012 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 (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * 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 7 * 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 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the Affero GNU General Public License 16 * You should have received a copy of the Affero GNU General Public License
17 * and the GNU General Public License along with this program. If not, see 17 * and the GNU General Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>. 18 * <http://www.gnu.org/licenses/>.
19 * 19 *
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23/* 23/*
24 * General convenience functions for deliantra. 24 * General convenience functions for deliantra.
199 199
200/******************************************************************************/ 200/******************************************************************************/
201 201
202refcnt_buf::refcnt_buf (size_t size) 202refcnt_buf::refcnt_buf (size_t size)
203{ 203{
204 _alloc (size); 204 static uint32_t empty_buf [2] = { 0, 1 }; // 2 == never deallocated
205 data = (char *)empty_buf + overhead;
206 assert (overhead == sizeof (empty_buf));
207 inc ();
205} 208}
206 209
207refcnt_buf::refcnt_buf (void *data, size_t size) 210refcnt_buf::refcnt_buf (void *data, size_t size)
208{ 211{
209 _alloc (size); 212 _alloc (size);
213refcnt_buf::~refcnt_buf () 216refcnt_buf::~refcnt_buf ()
214{ 217{
215 dec (); 218 dec ();
216} 219}
217 220
221void
222refcnt_buf::_dealloc ()
223{
224 sfree<char> (data - overhead, size () + overhead);
225}
226
218refcnt_buf & 227refcnt_buf &
219refcnt_buf::operator =(const refcnt_buf &src) 228refcnt_buf::operator =(const refcnt_buf &src)
220{ 229{
221 dec (); 230 dec ();
222 data = src.data; 231 data = src.data;
223 ++_refcnt (); 232 inc ();
224 return *this; 233 return *this;
225} 234}
226 235
227/******************************************************************************/ 236/******************************************************************************/
228 237

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines