Przeglądaj źródła

Add a ZERO macro to clear arrays

Scott Lahteine 8 lat temu
rodzic
commit
5f5a55a0de

+ 1
- 1
Marlin/Marlin_main.cpp Wyświetl plik

@@ -3145,7 +3145,7 @@ inline void gcode_G4() {
3145 3145
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
3146 3146
     #endif
3147 3147
     // Init the current position of all carriages to 0,0,0
3148
-    memset(current_position, 0, sizeof(current_position));
3148
+    ZERO(current_position);
3149 3149
     sync_plan_position();
3150 3150
 
3151 3151
     // Move all carriages together linearly until an endstop is hit.

+ 1
- 1
Marlin/SdBaseFile.cpp Wyświetl plik

@@ -674,7 +674,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile,
674 674
       index = 0;
675 675
     }
676 676
     // initialize as empty file
677
-    memset(p, 0, sizeof(dir_t));
677
+    ZERO(p);
678 678
     memcpy(p->name, dname, 11);
679 679
 
680 680
     // set timestamps

+ 1
- 1
Marlin/cardreader.cpp Wyświetl plik

@@ -36,7 +36,7 @@ CardReader::CardReader() {
36 36
   sdpos = 0;
37 37
   workDirDepth = 0;
38 38
   file_subcall_ctr = 0;
39
-  memset(workDirParents, 0, sizeof(workDirParents));
39
+  ZERO(workDirParents);
40 40
 
41 41
   autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
42 42
   autostart_index = 0;

+ 1
- 0
Marlin/macros.h Wyświetl plik

@@ -78,6 +78,7 @@
78 78
 #define NUMERIC(a) ((a) >= '0' && '9' >= (a))
79 79
 #define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-')
80 80
 #define COUNT(a) (sizeof(a)/sizeof(*a))
81
+#define ZERO(a) memset(a,0,sizeof(a))
81 82
 
82 83
 // Macros for initializing arrays
83 84
 #define ARRAY_6(v1, v2, v3, v4, v5, v6, args...) { v1, v2, v3, v4, v5, v6 }

+ 1
- 1
Marlin/mesh_bed_leveling.cpp Wyświetl plik

@@ -31,7 +31,7 @@
31 31
   void mesh_bed_leveling::reset() {
32 32
     status = MBL_STATUS_NONE;
33 33
     z_offset = 0;
34
-    memset(z_values, 0, sizeof(z_values));
34
+    ZERO(z_values);
35 35
   }
36 36
 
37 37
 #endif  // MESH_BED_LEVELING

+ 3
- 3
Marlin/planner.cpp Wyświetl plik

@@ -137,8 +137,8 @@ Planner::Planner() { init(); }
137 137
 
138 138
 void Planner::init() {
139 139
   block_buffer_head = block_buffer_tail = 0;
140
-  memset(position, 0, sizeof(position));
141
-  memset(previous_speed, 0, sizeof(previous_speed));
140
+  ZERO(position);
141
+  ZERO(previous_speed);
142 142
   previous_nominal_speed = 0.0;
143 143
   #if ABL_PLANAR
144 144
     bed_level_matrix.set_to_identity();
@@ -1266,7 +1266,7 @@ void Planner::_set_position_mm(const float &a, const float &b, const float &c, c
1266 1266
   stepper.set_position(na, nb, nc, ne);
1267 1267
   previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
1268 1268
 
1269
-  memset(previous_speed, 0, sizeof(previous_speed));
1269
+  ZERO(previous_speed);
1270 1270
 }
1271 1271
 
1272 1272
 void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {

Ładowanie…
Anuluj
Zapisz