Skip to content

Commit d8c117d

Browse files
gdinhBenBrock
andauthored
change filename vars to const char* (#8)
* change filenames to const char* --------- Co-authored-by: Benjamin Brock <[email protected]>
1 parent 905d402 commit d8c117d

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

examples/benchmark_write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void flush_writes() {
6060
#endif
6161
}
6262

63-
void delete_file(char* file_name) {
63+
void delete_file(const char* file_name) {
6464
char command[2048];
6565
snprintf(command, 2047, "rm %s", file_name);
6666
system(command);

include/binsparse/detail/parse_dataset.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bsp_fdataset_info_t bsp_parse_fdataset_string(char* str) {
3535
}
3636
}
3737

38-
char* bsp_get_file_extension(char* file_name) {
38+
const char* bsp_get_file_extension(const char* file_name) {
3939
int64_t len = strlen(file_name);
4040
for (int64_t i = len - 1; i >= 0; i--) {
4141
if (file_name[i] == '.') {

include/binsparse/hdf5_wrapper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// Write an array to a dataset / file
99
// Returns 0 on success, nonzero on error.
10-
int bsp_write_array(hid_t f, char* label, bsp_array_t array,
10+
int bsp_write_array(hid_t f, const char* label, bsp_array_t array,
1111
int compression_level) {
1212
if (array.type == BSP_COMPLEX_FLOAT32 || array.type == BSP_COMPLEX_FLOAT64) {
1313
array = bsp_complex_array_to_fp(array);
@@ -61,7 +61,7 @@ int bsp_write_array(hid_t f, char* label, bsp_array_t array,
6161
return 0;
6262
}
6363

64-
bsp_array_t bsp_read_array(hid_t f, char* label) {
64+
bsp_array_t bsp_read_array(hid_t f, const char* label) {
6565
hid_t dset = H5Dopen2(f, label, H5P_DEFAULT);
6666

6767
if (dset == H5I_INVALID_HID) {
@@ -100,7 +100,7 @@ bsp_array_t bsp_read_array(hid_t f, char* label) {
100100
return array;
101101
}
102102

103-
void bsp_write_attribute(hid_t f, char* label, char* string) {
103+
void bsp_write_attribute(hid_t f, const char* label, const char* string) {
104104
hid_t strtype = H5Tcopy(H5T_C_S1);
105105
H5Tset_size(strtype, strlen(string));
106106
H5Tset_cset(strtype, H5T_CSET_UTF8);
@@ -116,7 +116,7 @@ void bsp_write_attribute(hid_t f, char* label, char* string) {
116116
H5Sclose(dataspace);
117117
}
118118

119-
char* bsp_read_attribute(hid_t f, char* label) {
119+
char* bsp_read_attribute(hid_t f, const char* label) {
120120
hid_t attribute = H5Aopen(f, label, H5P_DEFAULT);
121121
hid_t strtype = H5Aget_type(attribute);
122122

include/binsparse/matrix_market/matrix_market_inspector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef struct bsp_mm_metadata {
2626
char* comments;
2727
} bsp_mm_metadata;
2828

29-
bsp_mm_metadata bsp_mmread_metadata(char* file_path) {
29+
bsp_mm_metadata bsp_mmread_metadata(const char* file_path) {
3030
FILE* f = fopen(file_path, "r");
3131

3232
assert(f != NULL);

include/binsparse/matrix_market/matrix_market_read.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#include <binsparse/matrix_market/matrix_market_inspector.h>
1010
#include <binsparse/matrix_market/matrix_market_type_t.h>
1111

12-
bsp_matrix_t bsp_mmread_explicit_array(char* file_path, bsp_type_t value_type,
12+
bsp_matrix_t bsp_mmread_explicit_array(const char* file_path,
13+
bsp_type_t value_type,
1314
bsp_type_t index_type) {
1415
bsp_mm_metadata metadata = bsp_mmread_metadata(file_path);
1516

@@ -96,7 +97,7 @@ bsp_matrix_t bsp_mmread_explicit_array(char* file_path, bsp_type_t value_type,
9697
return matrix;
9798
}
9899

99-
bsp_matrix_t bsp_mmread_explicit_coordinate(char* file_path,
100+
bsp_matrix_t bsp_mmread_explicit_coordinate(const char* file_path,
100101
bsp_type_t value_type,
101102
bsp_type_t index_type) {
102103
bsp_mm_metadata metadata = bsp_mmread_metadata(file_path);
@@ -254,7 +255,7 @@ bsp_matrix_t bsp_mmread_explicit_coordinate(char* file_path,
254255
return matrix;
255256
}
256257

257-
bsp_matrix_t bsp_mmread_explicit(char* file_path, bsp_type_t value_type,
258+
bsp_matrix_t bsp_mmread_explicit(const char* file_path, bsp_type_t value_type,
258259
bsp_type_t index_type) {
259260
bsp_mm_metadata metadata = bsp_mmread_metadata(file_path);
260261

@@ -267,7 +268,7 @@ bsp_matrix_t bsp_mmread_explicit(char* file_path, bsp_type_t value_type,
267268
}
268269
}
269270

270-
bsp_matrix_t bsp_mmread(char* file_path) {
271+
bsp_matrix_t bsp_mmread(const char* file_path) {
271272
bsp_mm_metadata metadata = bsp_mmread_metadata(file_path);
272273

273274
bsp_type_t value_type;

include/binsparse/matrix_market/matrix_market_write.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <binsparse/matrix_market/matrix_market_type_t.h>
88

9-
void bsp_mmwrite(char* file_path, bsp_matrix_t matrix) {
9+
void bsp_mmwrite(const char* file_path, bsp_matrix_t matrix) {
1010
FILE* f = fopen(file_path, "w");
1111

1212
assert(f != NULL);

include/binsparse/read_matrix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bsp_matrix_t bsp_read_matrix_from_group(hid_t f) {
105105
return matrix;
106106
}
107107

108-
size_t bsp_final_dot(char* str) {
108+
size_t bsp_final_dot(const char* str) {
109109
size_t dot_idx = 0;
110110
for (size_t i = 0; str[i] != '\0'; i++) {
111111
if (str[i] == '.') {
@@ -115,7 +115,7 @@ size_t bsp_final_dot(char* str) {
115115
return dot_idx;
116116
}
117117

118-
bsp_matrix_t bsp_read_matrix(char* file_name, char* group) {
118+
bsp_matrix_t bsp_read_matrix(const char* file_name, char* group) {
119119
if (group == NULL) {
120120
size_t idx = bsp_final_dot(file_name);
121121
if (strcmp(file_name + idx, ".hdf5") == 0 ||

include/binsparse/write_matrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int bsp_write_matrix_to_group(hid_t f, bsp_matrix_t matrix, cJSON* user_json,
121121
return 0;
122122
}
123123

124-
int bsp_write_matrix(char* fname, bsp_matrix_t matrix, char* group,
124+
int bsp_write_matrix(const char* fname, bsp_matrix_t matrix, char* group,
125125
cJSON* user_json, int compression_level) {
126126
if (group == NULL) {
127127
hid_t f = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

0 commit comments

Comments
 (0)