Skip to content

Commit de1517d

Browse files
ikegami-tigaw
authored andcommitted
util: rename table_init() to table_create()
Also changed the function to return calloc() instead. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 4606d64 commit de1517d

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

nvme-print-stdout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5735,7 +5735,7 @@ static void stdout_tabular_subsystem_topology_multipath(nvme_subsystem_t s)
57355735
{"State", LEFT, 0},
57365736
};
57375737

5738-
t = table_init();
5738+
t = table_create();
57395739
if (!t) {
57405740
printf("Failed to init table\n");
57415741
return;
@@ -5931,7 +5931,7 @@ static void stdout_tabular_subsystem_topology(nvme_subsystem_t s)
59315931
{"State", LEFT, 0},
59325932
};
59335933

5934-
t = table_init();
5934+
t = table_create();
59355935
if (!t) {
59365936
printf("Failed to init table\n");
59375937
return;

util/table.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,21 +231,14 @@ void table_add_row(struct table *t, int row_id)
231231
}
232232
}
233233

234-
struct table *table_init(void)
234+
struct table *table_create(void)
235235
{
236-
struct table *t = malloc(sizeof(struct table));
237-
238-
if (!t)
239-
return NULL;
240-
241-
memset(t, 0, sizeof(struct table));
242-
243-
return t;
236+
return calloc(1, sizeof(struct table));
244237
}
245238

246239
struct table *table_init_with_columns(struct table_column *c, int num_columns)
247240
{
248-
struct table *t = table_init();
241+
struct table *t = table_create();
249242

250243
if (!t)
251244
return NULL;
@@ -256,7 +249,6 @@ struct table *table_init_with_columns(struct table_column *c, int num_columns)
256249
}
257250

258251
return t;
259-
260252
}
261253

262254
static int table_add_column(struct table *t, struct table_column *c)

util/table.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static inline void table_set_value_unsigned_long(struct table *t, int col,
135135
v->type = FMT_UNSIGNED_LONG;
136136
}
137137

138-
struct table *table_init(void);
138+
struct table *table_create(void);
139139
int table_add_columns(struct table *t, struct table_column *c, int num_columns);
140140
int table_add_columns_filter(struct table *t, struct table_column *c,
141141
int num_columns,
@@ -151,7 +151,7 @@ void table_free(struct table *t);
151151
* @c: Column definitions
152152
* @num_columns:Number of columns
153153
*
154-
* This is a function combined table_init() and table_add_columns().
154+
* This is a function combined table_create() and table_add_columns().
155155
*
156156
* Return: The table instance, or NULL if unsuccessful. If allocated, the caller
157157
* is responsible to free the table.

0 commit comments

Comments
 (0)