Browse Source

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

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
1f74fa2cad
1 changed files with 8 additions and 11 deletions
  1. 8
    11
      src/hci/mucurses/slk.c

+ 8
- 11
src/hci/mucurses/slk.c View File

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

Loading…
Cancel
Save