Mercurial > dwindows
comparison dwtest.c @ 227:5e6d8e024214
Use calloc instead of malloc so line buffers aren't filled with garbage.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 05 Feb 2003 06:20:43 +0000 |
parents | 2aee0b23e880 |
children | 4166c18586e5 |
comparison
equal
deleted
inserted
replaced
226:2aee0b23e880 | 227:5e6d8e024214 |
---|---|
68 lp = (char **)calloc( 1000,sizeof(char *)); | 68 lp = (char **)calloc( 1000,sizeof(char *)); |
69 /* should test for out of memory */ | 69 /* should test for out of memory */ |
70 max_linewidth=0; | 70 max_linewidth=0; |
71 for ( i = 0; i < 1000; i++ ) | 71 for ( i = 0; i < 1000; i++ ) |
72 { | 72 { |
73 lp[i] = (char *)malloc( 1025 ); | 73 lp[i] = (char *)calloc(1, 1025); |
74 if ( fgets( lp[i], 1024, fp ) == NULL ) | 74 if ( fgets( lp[i], 1024, fp ) == NULL ) |
75 break; | 75 break; |
76 len = strlen( lp[i] ); | 76 len = strlen( lp[i] ); |
77 if ( len > max_linewidth ) | 77 if ( len > max_linewidth ) |
78 max_linewidth = len; | 78 max_linewidth = len; |