Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
27ca0db7
Commit
27ca0db7
authored
Jan 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/Alloc: new library replacing GLib's g_malloc()
parent
49f34fbf
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
208 additions
and
56 deletions
+208
-56
Makefile.am
Makefile.am
+1
-0
DecoderBuffer.cxx
src/DecoderBuffer.cxx
+1
-0
Directory.cxx
src/Directory.cxx
+5
-5
Page.cxx
src/Page.cxx
+4
-4
PlaylistSave.cxx
src/PlaylistSave.cxx
+3
-4
Song.cxx
src/Song.cxx
+5
-5
UpdateWalk.cxx
src/UpdateWalk.cxx
+4
-4
CueParser.cxx
src/cue/CueParser.cxx
+3
-4
GmeDecoderPlugin.cxx
src/decoder/GmeDecoderPlugin.cxx
+3
-2
SidplayDecoderPlugin.cxx
src/decoder/SidplayDecoderPlugin.cxx
+4
-3
ServerSocket.cxx
src/event/ServerSocket.cxx
+3
-4
ArchiveInputPlugin.cxx
src/input/ArchiveInputPlugin.cxx
+7
-6
OSXOutputPlugin.cxx
src/output/OSXOutputPlugin.cxx
+1
-1
TagBuilder.cxx
src/tag/TagBuilder.cxx
+2
-3
TagConfig.cxx
src/tag/TagConfig.cxx
+5
-2
TagPool.cxx
src/tag/TagPool.cxx
+1
-0
TagString.cxx
src/tag/TagString.cxx
+10
-5
Alloc.cxx
src/util/Alloc.cxx
+76
-0
Alloc.hxx
src/util/Alloc.hxx
+67
-0
VarSize.hxx
src/util/VarSize.hxx
+3
-4
No files found.
Makefile.am
View file @
27ca0db7
...
...
@@ -251,6 +251,7 @@ libutil_a_SOURCES = \
src/util/Macros.hxx
\
src/util/Cast.hxx
\
src/util/Clamp.hxx
\
src/util/Alloc.cxx src/util/Alloc.hxx
\
src/util/VarSize.hxx
\
src/util/Error.cxx src/util/Error.hxx
\
src/util/Domain.hxx
\
...
...
src/DecoderBuffer.cxx
View file @
27ca0db7
...
...
@@ -25,6 +25,7 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
struct
DecoderBuffer
{
Decoder
*
decoder
;
...
...
src/Directory.cxx
View file @
27ca0db7
...
...
@@ -174,7 +174,7 @@ Directory::LookupDirectory(const char *uri)
if
(
isRootDirectory
(
uri
))
return
this
;
char
*
duplicated
=
g_
strdup
(
uri
),
*
name
=
duplicated
;
char
*
duplicated
=
x
strdup
(
uri
),
*
name
=
duplicated
;
Directory
*
d
=
this
;
while
(
1
)
{
...
...
@@ -194,7 +194,7 @@ Directory::LookupDirectory(const char *uri)
name
=
slash
+
1
;
}
g_
free
(
duplicated
);
free
(
duplicated
);
return
d
;
}
...
...
@@ -244,7 +244,7 @@ Directory::LookupSong(const char *uri)
assert
(
holding_db_lock
());
assert
(
uri
!=
nullptr
);
duplicated
=
g_
strdup
(
uri
);
duplicated
=
x
strdup
(
uri
);
base
=
strrchr
(
duplicated
,
'/'
);
Directory
*
d
=
this
;
...
...
@@ -252,7 +252,7 @@ Directory::LookupSong(const char *uri)
*
base
++
=
0
;
d
=
d
->
LookupDirectory
(
duplicated
);
if
(
d
==
nullptr
)
{
g_
free
(
duplicated
);
free
(
duplicated
);
return
nullptr
;
}
}
else
...
...
@@ -261,7 +261,7 @@ Directory::LookupSong(const char *uri)
Song
*
song
=
d
->
FindSong
(
base
);
assert
(
song
==
nullptr
||
song
->
parent
==
d
);
g_
free
(
duplicated
);
free
(
duplicated
);
return
song
;
}
...
...
src/Page.cxx
View file @
27ca0db7
...
...
@@ -19,18 +19,18 @@
#include "config.h"
#include "Page.hxx"
#include <glib.h>
#include "util/Alloc.hxx"
#include <new>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
Page
*
Page
::
Create
(
size_t
size
)
{
void
*
p
=
g_m
alloc
(
sizeof
(
Page
)
+
size
-
void
*
p
=
x
alloc
(
sizeof
(
Page
)
+
size
-
sizeof
(
Page
::
data
));
return
::
new
(
p
)
Page
(
size
);
}
...
...
@@ -63,7 +63,7 @@ Page::Unref()
if
(
unused
)
{
this
->
Page
::~
Page
();
g_
free
(
this
);
free
(
this
);
}
return
unused
;
...
...
src/PlaylistSave.cxx
View file @
27ca0db7
...
...
@@ -28,12 +28,11 @@
#include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx"
#include "fs/FileSystem.hxx"
#include "util/Alloc.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include <glib.h>
#include <string.h>
void
...
...
@@ -127,7 +126,7 @@ playlist_load_spl(struct playlist &playlist, PlayerControl &pc,
if
((
playlist
.
AppendURI
(
pc
,
uri_utf8
.
c_str
()))
!=
PlaylistResult
::
SUCCESS
)
{
/* for windows compatibility, convert slashes */
char
*
temp2
=
g_
strdup
(
uri_utf8
.
c_str
());
char
*
temp2
=
x
strdup
(
uri_utf8
.
c_str
());
char
*
p
=
temp2
;
while
(
*
p
)
{
if
(
*
p
==
'\\'
)
...
...
@@ -139,7 +138,7 @@ playlist_load_spl(struct playlist &playlist, PlayerControl &pc,
FormatError
(
playlist_domain
,
"can't add file
\"
%s
\"
"
,
temp2
);
g_
free
(
temp2
);
free
(
temp2
);
}
}
...
...
src/Song.cxx
View file @
27ca0db7
...
...
@@ -21,11 +21,11 @@
#include "Song.hxx"
#include "Directory.hxx"
#include "tag/Tag.hxx"
#include <glib.h>
#include "util/Alloc.hxx"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
Directory
detached_root
;
...
...
@@ -39,7 +39,7 @@ song_alloc(const char *uri, Directory *parent)
assert
(
uri_length
);
Song
*
song
=
(
Song
*
)
g_m
alloc
(
sizeof
(
*
song
)
-
sizeof
(
song
->
uri
)
+
uri_length
+
1
);
x
alloc
(
sizeof
(
*
song
)
-
sizeof
(
song
->
uri
)
+
uri_length
+
1
);
song
->
tag
=
nullptr
;
memcpy
(
song
->
uri
,
uri
,
uri_length
+
1
);
...
...
@@ -72,7 +72,7 @@ Song::ReplaceURI(const char *new_uri)
new_song
->
mtime
=
mtime
;
new_song
->
start_ms
=
start_ms
;
new_song
->
end_ms
=
end_ms
;
g_
free
(
this
);
free
(
this
);
return
new_song
;
}
...
...
@@ -106,7 +106,7 @@ void
Song
::
Free
()
{
delete
tag
;
g_
free
(
this
);
free
(
this
);
}
void
...
...
src/UpdateWalk.cxx
View file @
27ca0db7
...
...
@@ -38,14 +38,14 @@
#include "fs/Traits.hxx"
#include "fs/FileSystem.hxx"
#include "fs/DirectoryReader.hxx"
#include "util/Alloc.hxx"
#include "util/UriUtil.hxx"
#include "Log.hxx"
#include <glib.h>
#include <assert.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
bool
walk_discard
;
...
...
@@ -426,7 +426,7 @@ static Directory *
directory_make_uri_parent_checked
(
const
char
*
uri
)
{
Directory
*
directory
=
db_get_root
();
char
*
duplicated
=
g_
strdup
(
uri
);
char
*
duplicated
=
x
strdup
(
uri
);
char
*
name_utf8
=
duplicated
,
*
slash
;
while
((
slash
=
strchr
(
name_utf8
,
'/'
))
!=
nullptr
)
{
...
...
@@ -443,7 +443,7 @@ directory_make_uri_parent_checked(const char *uri)
name_utf8
=
slash
+
1
;
}
g_
free
(
duplicated
);
free
(
duplicated
);
return
directory
;
}
...
...
src/cue/CueParser.cxx
View file @
27ca0db7
...
...
@@ -19,13 +19,12 @@
#include "config.h"
#include "CueParser.hxx"
#include "util/Alloc.hxx"
#include "util/StringUtil.hxx"
#include "util/CharUtil.hxx"
#include "Song.hxx"
#include "tag/Tag.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
...
...
@@ -290,9 +289,9 @@ CueParser::Feed(const char *line)
assert
(
!
end
);
assert
(
line
!=
nullptr
);
char
*
allocated
=
g_
strdup
(
line
);
char
*
allocated
=
x
strdup
(
line
);
Feed2
(
allocated
);
g_
free
(
allocated
);
free
(
allocated
);
}
void
...
...
src/decoder/GmeDecoderPlugin.cxx
View file @
27ca0db7
...
...
@@ -22,6 +22,7 @@
#include "DecoderAPI.hxx"
#include "CheckAudioFormat.hxx"
#include "tag/TagHandler.hxx"
#include "util/Alloc.hxx"
#include "util/FormatString.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
...
...
@@ -53,7 +54,7 @@ static char *
get_container_name
(
const
char
*
path_fs
)
{
const
char
*
subtune_suffix
=
uri_get_suffix
(
path_fs
);
char
*
path_container
=
g_
strdup
(
path_fs
);
char
*
path_container
=
x
strdup
(
path_fs
);
char
pat
[
64
];
snprintf
(
pat
,
sizeof
(
pat
),
"%s%s"
,
...
...
@@ -137,7 +138,7 @@ gme_file_decode(Decoder &decoder, const char *path_fs)
Music_Emu
*
emu
;
const
char
*
gme_err
=
gme_open_file
(
path_container
,
&
emu
,
GME_SAMPLE_RATE
);
g_
free
(
path_container
);
free
(
path_container
);
if
(
gme_err
!=
nullptr
)
{
LogWarning
(
gme_domain
,
gme_err
);
return
;
...
...
src/decoder/SidplayDecoderPlugin.cxx
View file @
27ca0db7
...
...
@@ -21,6 +21,7 @@
#include "SidplayDecoderPlugin.hxx"
#include "../DecoderAPI.hxx"
#include "tag/TagHandler.hxx"
#include "util/Alloc.hxx"
#include "util/Domain.hxx"
#include "system/ByteOrder.hxx"
#include "Log.hxx"
...
...
@@ -121,7 +122,7 @@ sidplay_finish()
static
char
*
get_container_name
(
const
char
*
path_fs
)
{
char
*
path_container
=
g_
strdup
(
path_fs
);
char
*
path_container
=
strdup
(
path_fs
);
if
(
!
g_pattern_match
(
path_with_subtune
,
strlen
(
path_container
),
path_container
,
nullptr
))
...
...
@@ -163,9 +164,9 @@ get_song_length(const char *path_fs)
if
(
songlength_database
==
nullptr
)
return
-
1
;
gchar
*
sid_file
=
get_container_name
(
path_fs
);
char
*
sid_file
=
get_container_name
(
path_fs
);
SidTuneMod
tune
(
sid_file
);
g_
free
(
sid_file
);
free
(
sid_file
);
if
(
!
tune
)
{
LogWarning
(
sidplay_domain
,
"failed to load file for calculating md5 sum"
);
...
...
src/event/ServerSocket.cxx
View file @
27ca0db7
...
...
@@ -31,12 +31,11 @@
#include "system/fd_util.h"
#include "fs/AllocatedPath.hxx"
#include "fs/FileSystem.hxx"
#include "util/Alloc.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
#include <glib.h>
#include <string>
#include <algorithm>
...
...
@@ -79,7 +78,7 @@ public:
parent
(
_parent
),
serial
(
_serial
),
path
(
AllocatedPath
::
Null
()),
address_length
(
_address_length
),
address
((
sockaddr
*
)
g_
memdup
(
_address
,
_address_length
))
address
((
sockaddr
*
)
x
memdup
(
_address
,
_address_length
))
{
assert
(
_address
!=
nullptr
);
assert
(
_address_length
>
0
);
...
...
@@ -89,7 +88,7 @@ public:
OneServerSocket
&
operator
=
(
const
OneServerSocket
&
other
)
=
delete
;
~
OneServerSocket
()
{
g_
free
(
address
);
free
(
address
);
if
(
IsDefined
())
Close
();
...
...
src/input/ArchiveInputPlugin.cxx
View file @
27ca0db7
...
...
@@ -26,9 +26,10 @@
#include "ArchiveFile.hxx"
#include "InputPlugin.hxx"
#include "fs/Traits.hxx"
#include "util/Alloc.hxx"
#include "Log.hxx"
#include <
g
lib.h>
#include <
std
lib.h>
/**
* select correct archive plugin to handle the input stream
...
...
@@ -49,13 +50,13 @@ input_archive_open(const char *pathname,
if
(
!
PathTraitsFS
::
IsAbsolute
(
pathname
))
return
nullptr
;
char
*
pname
=
g_
strdup
(
pathname
);
char
*
pname
=
strdup
(
pathname
);
// archive_lookup will modify pname when true is returned
const
char
*
archive
,
*
filename
,
*
suffix
;
if
(
!
archive_lookup
(
pname
,
&
archive
,
&
filename
,
&
suffix
))
{
FormatDebug
(
archive_domain
,
"not an archive, lookup %s failed"
,
pname
);
g_
free
(
pname
);
free
(
pname
);
return
nullptr
;
}
...
...
@@ -64,19 +65,19 @@ input_archive_open(const char *pathname,
if
(
!
arplug
)
{
FormatWarning
(
archive_domain
,
"can't handle archive %s"
,
archive
);
g_
free
(
pname
);
free
(
pname
);
return
nullptr
;
}
auto
file
=
archive_file_open
(
arplug
,
archive
,
error
);
if
(
file
==
nullptr
)
{
g_
free
(
pname
);
free
(
pname
);
return
nullptr
;
}
//setup fileops
is
=
file
->
OpenStream
(
filename
,
mutex
,
cond
,
error
);
g_
free
(
pname
);
free
(
pname
);
file
->
Close
();
return
is
;
...
...
src/output/OSXOutputPlugin.cxx
View file @
27ca0db7
...
...
@@ -72,7 +72,7 @@ osx_output_configure(OSXOutput *oo, const config_param ¶m)
}
else
{
oo
->
component_subtype
=
kAudioUnitSubType_HALOutput
;
/* XXX am I supposed to
g_
strdup() this? */
/* XXX am I supposed to strdup() this? */
oo
->
device_name
=
device
;
}
}
...
...
src/tag/TagBuilder.cxx
View file @
27ca0db7
...
...
@@ -24,10 +24,9 @@
#include "TagString.hxx"
#include "Tag.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
TagBuilder
::
TagBuilder
(
const
Tag
&
other
)
:
time
(
other
.
time
),
has_playlist
(
other
.
has_playlist
)
...
...
@@ -187,7 +186,7 @@ TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
auto
i
=
tag_pool_get_item
(
type
,
value
,
length
);
tag_pool_lock
.
unlock
();
g_
free
(
p
);
free
(
p
);
items
.
push_back
(
i
);
}
...
...
src/tag/TagConfig.cxx
View file @
27ca0db7
...
...
@@ -24,12 +24,15 @@
#include "ConfigGlobal.hxx"
#include "ConfigOption.hxx"
#include "system/FatalError.hxx"
#include "util/Alloc.hxx"
#include "util/ASCII.hxx"
#include <glib.h>
#include <algorithm>
#include <stdlib.h>
void
TagLoadConfig
()
{
...
...
@@ -44,7 +47,7 @@ TagLoadConfig()
bool
quit
=
false
;
char
*
temp
,
*
c
,
*
s
;
temp
=
c
=
s
=
g_
strdup
(
value
);
temp
=
c
=
s
=
x
strdup
(
value
);
do
{
if
(
*
s
==
','
||
*
s
==
'\0'
)
{
if
(
*
s
==
'\0'
)
...
...
@@ -68,5 +71,5 @@ TagLoadConfig()
s
++
;
}
while
(
!
quit
);
g_
free
(
temp
);
free
(
temp
);
}
src/tag/TagPool.cxx
View file @
27ca0db7
...
...
@@ -25,6 +25,7 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
Mutex
tag_pool_lock
;
...
...
src/tag/TagString.cxx
View file @
27ca0db7
...
...
@@ -19,11 +19,13 @@
#include "config.h"
#include "TagString.hxx"
#include "util/Alloc.hxx"
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
/**
* Replace invalid sequences with the question mark.
...
...
@@ -33,7 +35,7 @@ patch_utf8(const char *src, size_t length, const gchar *end)
{
/* duplicate the string, and replace invalid bytes in that
buffer */
char
*
dest
=
g_
strdup
(
src
);
char
*
dest
=
x
strdup
(
src
);
do
{
dest
[
end
-
src
]
=
'?'
;
...
...
@@ -58,9 +60,12 @@ fix_utf8(const char *str, size_t length)
/* no, it's not - try to import it from ISO-Latin-1 */
temp
=
g_convert
(
str
,
length
,
"utf-8"
,
"iso-8859-1"
,
nullptr
,
&
written
,
nullptr
);
if
(
temp
!=
nullptr
)
if
(
temp
!=
nullptr
)
{
/* success! */
return
temp
;
char
*
p
=
xstrdup
(
temp
);
g_free
(
temp
);
return
p
;
}
/* no, still broken - there's no medication, just patch
invalid sequences */
...
...
@@ -96,7 +101,7 @@ clear_non_printable(const char *p, size_t length)
if
(
first
==
nullptr
)
return
nullptr
;
dest
=
g_
strndup
(
p
,
length
);
dest
=
x
strndup
(
p
,
length
);
for
(
size_t
i
=
first
-
p
;
i
<
length
;
++
i
)
if
(
char_is_non_printable
(
dest
[
i
]))
...
...
@@ -120,7 +125,7 @@ FixTagString(const char *p, size_t length)
if
(
cleared
==
nullptr
)
cleared
=
utf8
;
else
g_
free
(
utf8
);
free
(
utf8
);
return
cleared
;
}
src/util/Alloc.cxx
0 → 100644
View file @
27ca0db7
/*
* Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "Alloc.hxx"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
gcc_noreturn
static
void
oom
()
{
(
void
)
write
(
STDERR_FILENO
,
"Out of memory
\n
"
,
14
);
_exit
(
1
);
}
void
*
xalloc
(
size_t
size
)
{
void
*
p
=
malloc
(
size
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
return
p
;
}
void
*
xmemdup
(
const
void
*
s
,
size_t
size
)
{
void
*
p
=
xalloc
(
size
);
memcpy
(
p
,
s
,
size
);
return
p
;
}
char
*
xstrdup
(
const
char
*
s
)
{
char
*
p
=
strdup
(
s
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
return
p
;
}
char
*
xstrndup
(
const
char
*
s
,
size_t
n
)
{
#ifdef WIN32
char
*
p
=
(
char
*
)
xalloc
(
n
+
1
);
memcpy
(
p
,
s
,
n
);
p
[
n
]
=
0
;
#else
char
*
p
=
strndup
(
s
,
n
);
if
(
gcc_unlikely
(
p
==
nullptr
))
oom
();
#endif
return
p
;
}
src/util/Alloc.hxx
0 → 100644
View file @
27ca0db7
/*
* Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ALLOC_HXX
#define MPD_ALLOC_HXX
#include "Compiler.h"
#include <stddef.h>
/**
* Allocate memory. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
void
*
xalloc
(
size_t
size
);
/**
* Duplicate memory. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_nonnull_all
void
*
xmemdup
(
const
void
*
s
,
size_t
size
);
/**
* Duplicate a string. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_nonnull_all
char
*
xstrdup
(
const
char
*
s
);
/**
* Duplicate a string. Use free() to free it.
*
* This function never fails; in out-of-memory situations, it aborts
* the process.
*/
gcc_malloc
gcc_nonnull_all
char
*
xstrndup
(
const
char
*
s
,
size_t
n
);
#endif
src/util/VarSize.hxx
View file @
27ca0db7
...
...
@@ -30,14 +30,13 @@
#ifndef MPD_VAR_SIZE_HXX
#define MPD_VAR_SIZE_HXX
#include "Alloc.hxx"
#include "Compiler.h"
#include <type_traits>
#include <utility>
#include <new>
#include <glib.h>
/**
* Allocate and construct a variable-size object. That is useful for
* example when you want to store a variable-length string as the last
...
...
@@ -61,7 +60,7 @@ NewVarSize(size_t declared_tail_size, size_t real_tail_size, Args&&... args)
size_t
size
=
sizeof
(
T
)
-
declared_tail_size
+
real_tail_size
;
/* allocate memory */
T
*
instance
=
(
T
*
)
g_m
alloc
(
size
);
T
*
instance
=
(
T
*
)
x
alloc
(
size
);
/* call the constructor */
new
(
instance
)
T
(
std
::
forward
<
Args
>
(
args
)...);
...
...
@@ -78,7 +77,7 @@ DeleteVarSize(T *instance)
instance
->
T
::~
T
();
/* free memory */
g_
free
(
instance
);
free
(
instance
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment