Selaa lähdekoodia

Remove some unnecessary use of calloc() for tiny memory areas.

tags/v0.9.3
Michael Brown 18 vuotta sitten
vanhempi
commit
1f74fa2cad
1 muutettua tiedostoa jossa 8 lisäystä ja 11 poistoa
  1. 8
    11
      src/hci/mucurses/slk.c

+ 8
- 11
src/hci/mucurses/slk.c Näytä tiedosto

@@ -19,7 +19,7 @@ struct _softlabel {
19 19
 	   1: centre justify
20 20
 	   2: right justify
21 21
 	 */
22
-	unsigned short fmt;
22
+	unsigned int fmt;
23 23
 };
24 24
 
25 25
 struct _softlabelkeys {
@@ -31,12 +31,12 @@ struct _softlabelkeys {
31 31
 	   2: 4-4-4
32 32
 	   3: 4-4-4 with index line
33 33
 	*/
34
-	unsigned short fmt;
35
-	unsigned short max_label_len;
36
-	unsigned short maj_space_len;
37
-	unsigned short num_labels;
38
-	unsigned short num_spaces;
39
-	unsigned short *spaces;
34
+	unsigned int fmt;
35
+	unsigned int max_label_len;
36
+	unsigned int maj_space_len;
37
+	unsigned int num_labels;
38
+	unsigned int num_spaces;
39
+	unsigned int spaces[2];
40 40
 };
41 41
 
42 42
 struct _softlabelkeys *slks;
@@ -236,19 +236,16 @@ int slk_init ( int fmt ) {
236 236
 	switch(fmt) {
237 237
 	case 0:
238 238
 		nblocks = 8; nmaj = 2; nmin = 5;
239
-		slks->spaces = calloc(2, sizeof(unsigned short));
240 239
 		slks->spaces[0] = 2; slks->spaces[1] = 4;
241 240
 		break;
242 241
 	case 1:
243 242
 		nblocks = 8; nmaj = 1; nmin = 6;
244
-		slks->spaces = calloc(1, sizeof(unsigned short));
245 243
 		slks->spaces[0] = 3;
246 244
 		break;
247 245
 	case 2:
248 246
 		// same allocations as format 3
249 247
 	case 3:
250 248
 		nblocks = 12; nmaj = 2; nmin = 9;
251
-		slks->spaces = calloc(2, sizeof(unsigned short));
252 249
 		slks->spaces[0] = 3; slks->spaces[1] = 7;
253 250
 		break;
254 251
 	default:
@@ -290,7 +287,7 @@ char* slk_label ( int labnum ) {
290 287
  * @ret rc	return status code
291 288
  */
292 289
 int slk_restore ( void ) {
293
-	unsigned short i, j,
290
+	unsigned int i, j,
294 291
 		*next_space, *last_space;
295 292
 	chtype space_ch;
296 293
 

Loading…
Peruuta
Tallenna