Blender  V2.93
spreadsheet_column.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #include "DNA_space_types.h"
18 
19 #include "MEM_guardedalloc.h"
20 
21 #include "BLI_hash.hh"
22 #include "BLI_string.h"
23 #include "BLI_string_ref.hh"
24 
25 #include "spreadsheet_column.hh"
26 
27 namespace blender::ed::spreadsheet {
28 
30 {
32  __func__);
33  return column_id;
34 }
35 
37 {
39  new_column_id->name = BLI_strdup(src_column_id->name);
40  return new_column_id;
41 }
42 
44 {
45  if (column_id->name != nullptr) {
46  MEM_freeN(column_id->name);
47  }
48  MEM_freeN(column_id);
49 }
50 
52 {
54  __func__);
55  column->id = column_id;
56  return column;
57 }
58 
60 {
61  SpreadsheetColumnID *new_column_id = spreadsheet_column_id_copy(src_column->id);
62  SpreadsheetColumn *new_column = spreadsheet_column_new(new_column_id);
63  return new_column;
64 }
65 
67 {
69  MEM_freeN(column);
70 }
71 
72 } // namespace blender::ed::spreadsheet
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:70
Read Guarded memory(de)allocation.
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
SpreadsheetColumn * spreadsheet_column_new(SpreadsheetColumnID *column_id)
SpreadsheetColumnID * spreadsheet_column_id_new()
void spreadsheet_column_free(SpreadsheetColumn *column)
void spreadsheet_column_id_free(SpreadsheetColumnID *column_id)
SpreadsheetColumnID * spreadsheet_column_id_copy(const SpreadsheetColumnID *src_column_id)
SpreadsheetColumn * spreadsheet_column_copy(const SpreadsheetColumn *src_column)
SpreadsheetColumnID * id