Skip to content

Commit 8a39dcb

Browse files
committed
bzero is obsolete and not part of the C standard, making it unavailable on some platforms like Android and Windows. memset achieves the same functionality, is standardized, and ensures broader compatibility across systems.
1 parent 9e9bef8 commit 8a39dcb

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/cloudsync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ int local_update_move_meta (sqlite3 *db, cloudsync_table_context *table, const c
18001800
bool cloudsync_buffer_free (cloudsync_network_payload *payload) {
18011801
if (payload) {
18021802
if (payload->buffer) cloudsync_memory_free(payload->buffer);
1803-
bzero(payload, sizeof(cloudsync_network_payload));
1803+
memset(payload, 0, sizeof(cloudsync_network_payload));
18041804
}
18051805

18061806
return false;
@@ -1825,7 +1825,7 @@ bool cloudsync_buffer_check (cloudsync_network_payload *payload, size_t needed)
18251825
}
18261826

18271827
void cloudsync_network_header_init (cloudsync_network_header *header, uint32_t expanded_size, uint16_t ncols, uint32_t nrows, uint64_t hash) {
1828-
bzero(header, sizeof(cloudsync_network_header));
1828+
memset(header, 0, sizeof(cloudsync_network_header));
18291829
assert(sizeof(cloudsync_network_header)==32);
18301830

18311831
int major, minor, patch;

src/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void *cloudsync_memory_zeroalloc (uint64_t size) {
108108
void *ptr = (void *)cloudsync_memory_alloc((sqlite3_uint64)size);
109109
if (!ptr) return NULL;
110110

111-
bzero(ptr, (size_t)size);
111+
memset(ptr, 0, (size_t)size);
112112
return ptr;
113113
}
114114

test/unit.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ bool do_test_merge (int nclients, bool print_result, bool cleanup_databases) {
20102010
bool result = false;
20112011
int rc = SQLITE_OK;
20122012

2013-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2013+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
20142014
if (nclients >= MAX_SIMULATED_CLIENTS) {
20152015
nclients = MAX_SIMULATED_CLIENTS;
20162016
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2083,7 +2083,7 @@ bool do_test_merge_2 (int nclients, int table_mask, bool print_result, bool clea
20832083
int rc = SQLITE_OK;
20842084
int nrows = NINSERT;
20852085

2086-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2086+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
20872087
if (nclients >= MAX_SIMULATED_CLIENTS) {
20882088
nclients = MAX_SIMULATED_CLIENTS;
20892089
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2194,7 +2194,7 @@ bool do_test_merge_4 (int nclients, bool print_result, bool cleanup_databases) {
21942194
bool result = false;
21952195
int rc = SQLITE_OK;
21962196

2197-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2197+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
21982198
if (nclients >= MAX_SIMULATED_CLIENTS) {
21992199
nclients = MAX_SIMULATED_CLIENTS;
22002200
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2282,7 +2282,7 @@ bool do_test_merge_5 (int nclients, bool print_result, bool cleanup_databases, b
22822282
bool result = false;
22832283
int rc = SQLITE_OK;
22842284

2285-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2285+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
22862286
if (nclients >= MAX_SIMULATED_CLIENTS) {
22872287
nclients = MAX_SIMULATED_CLIENTS;
22882288
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2365,7 +2365,7 @@ bool do_test_merge_alter_schema_1 (int nclients, bool print_result, bool cleanup
23652365
bool result = false;
23662366
int rc = SQLITE_OK;
23672367

2368-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2368+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
23692369
if (nclients >= MAX_SIMULATED_CLIENTS) {
23702370
nclients = MAX_SIMULATED_CLIENTS;
23712371
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2453,7 +2453,7 @@ bool do_test_merge_alter_schema_2 (int nclients, bool print_result, bool cleanup
24532453
bool result = false;
24542454
int rc = SQLITE_OK;
24552455

2456-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2456+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
24572457
if (nclients >= MAX_SIMULATED_CLIENTS) {
24582458
nclients = MAX_SIMULATED_CLIENTS;
24592459
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2542,7 +2542,7 @@ bool do_test_prikey (int nclients, bool print_result, bool cleanup_databases) {
25422542
bool result = false;
25432543
int rc = SQLITE_OK;
25442544

2545-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2545+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
25462546
if (nclients >= MAX_SIMULATED_CLIENTS) {
25472547
nclients = MAX_SIMULATED_CLIENTS;
25482548
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2660,7 +2660,7 @@ bool do_test_gos (int nclients, bool print_result, bool cleanup_databases) {
26602660
bool result = false;
26612661
int rc = SQLITE_OK;
26622662

2663-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2663+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
26642664
if (nclients >= MAX_SIMULATED_CLIENTS) {
26652665
nclients = MAX_SIMULATED_CLIENTS;
26662666
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2747,7 +2747,7 @@ bool do_test_network_encode_decode (int nclients, bool print_result, bool cleanu
27472747
bool result = false;
27482748
int rc = SQLITE_OK;
27492749

2750-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2750+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
27512751
if (nclients >= MAX_SIMULATED_CLIENTS) {
27522752
nclients = MAX_SIMULATED_CLIENTS;
27532753
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2840,7 +2840,7 @@ bool do_test_fill_initial_data(int nclients, bool print_result, bool cleanup_dat
28402840
bool result = false;
28412841
int rc = SQLITE_OK;
28422842

2843-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2843+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
28442844
if (nclients >= MAX_SIMULATED_CLIENTS) {
28452845
nclients = MAX_SIMULATED_CLIENTS;
28462846
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);
@@ -2925,7 +2925,7 @@ bool do_test_alter(int nclients, int alter_version, bool print_result, bool clea
29252925
bool result = false;
29262926
int rc = SQLITE_OK;
29272927

2928-
bzero(db, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
2928+
memset(db, 0, sizeof(sqlite3 *) * MAX_SIMULATED_CLIENTS);
29292929
if (nclients >= MAX_SIMULATED_CLIENTS) {
29302930
nclients = MAX_SIMULATED_CLIENTS;
29312931
printf("Number of test merge reduced to %d clients\n", MAX_SIMULATED_CLIENTS);

0 commit comments

Comments
 (0)