OSDN Git Service

[Fix] 画面左下部の情報が正しく表示されない
[hengbandforosx/hengbandosx.git] / src / term / z-virt.cpp
1 /* File: z-virt.c */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.
9  */
10
11 /* Purpose: Memory management routines -BEN- */
12
13 #include <cstring>
14
15 #include "term/z-virt.h"
16
17 /*!
18  * @brief str の複製を返す。戻り値は使用後に string_free() で解放すること。
19  *
20  * nullptr が渡された場合、nullptr を返す。
21  */
22 concptr string_make(const concptr str)
23 {
24     if (!str) {
25         return nullptr;
26     }
27
28     const auto bufsize = std::strlen(str) + 1;
29     auto *const buf = new char[bufsize];
30     std::strcpy(buf, str);
31
32     return buf;
33 }
34
35 /*!
36  * @brief string_make() で割り当てたバッファを解放する。
37  * @return 常に 0
38  *
39  * nullptr が渡された場合、何もせず 0 を返す。
40  */
41 errr string_free(const concptr str)
42 {
43     if (!str) {
44         return 0;
45     }
46
47     delete[] str;
48
49     return 0;
50 }