| author | Jens Thoms Toerring <jt@toerring.de> | 2017年08月17日 15:07:48 +0200 |
|---|---|---|
| committer | Jens Thoms Toerring <jt@toerring.de> | 2017年08月17日 15:07:48 +0200 |
| commit | 2529976938da01901b86fe3df1ee3b64b8b355ae (patch) | |
| tree | 1bd12877e687feec8ae5e529acbfb8f40aa48b0d | |
| parent | f209febdbb2bfa2a3a5b7842d25438b9218b68a8 (diff) | |
| download | xforms-clock.tar.gz | |
| -rw-r--r-- | demos/nnn.c | 4 | ||||
| -rw-r--r-- | demos/rescale.c | 2 | ||||
| -rw-r--r-- | fdesign/fd_attribs.c | 2 | ||||
| -rw-r--r-- | fdesign/fd_main.c | 2 | ||||
| -rw-r--r-- | fdesign/fd_printC.c | 8 | ||||
| -rw-r--r-- | image/image.c | 2 | ||||
| -rw-r--r-- | image/image_bmp.c | 6 | ||||
| -rw-r--r-- | image/image_disp.c | 8 | ||||
| -rw-r--r-- | image/image_scale.c | 2 | ||||
| -rw-r--r-- | image/image_text.c | 2 | ||||
| -rw-r--r-- | lib/asyn_io.c | 2 | ||||
| -rw-r--r-- | lib/clock.c | 13 | ||||
| -rw-r--r-- | lib/goodie_yesno.c | 4 | ||||
| -rw-r--r-- | lib/spinner.c | 10 |
diff --git a/demos/nnn.c b/demos/nnn.c index 09419db..078c151 100644 --- a/demos/nnn.c +++ b/demos/nnn.c @@ -61,7 +61,7 @@ main( int argc, fl_hide_form( cbform->newbut ); fl_free_form( cbform->newbut ); - free( cbform ); + fl_free( cbform ); fprintf( stderr,"sleeping\n" ); sleep( 2 ); @@ -83,7 +83,7 @@ FD_newbut * create_form_newbut( void ) { FL_OBJECT *obj; - FD_newbut *fdui = calloc( 1, sizeof *fdui ); + FD_newbut *fdui = fl_calloc( 1, sizeof *fdui ); fdui->newbut = fl_bgn_form( FL_NO_BOX, 310, 190 ); diff --git a/demos/rescale.c b/demos/rescale.c index 816a8fb..34a9cc9 100644 --- a/demos/rescale.c +++ b/demos/rescale.c @@ -46,7 +46,7 @@ FD_form * create_form_form(void) { FL_OBJECT *obj; - FD_form *fdui = calloc( 1, sizeof *fdui ); + FD_form *fdui = fl_calloc( 1, sizeof *fdui ); fdui->form = fl_bgn_form( FL_NO_BOX, 470, 370 ); diff --git a/fdesign/fd_attribs.c b/fdesign/fd_attribs.c index 4efd230..0b995aa 100644 --- a/fdesign/fd_attribs.c +++ b/fdesign/fd_attribs.c @@ -1018,7 +1018,7 @@ copy_shortcut( FL_OBJECT * dest, if ( i ) { - dest->shortcut = malloc( i * sizeof *dest->shortcut ); + dest->shortcut = fl_malloc( i * sizeof *dest->shortcut ); memcpy( dest->shortcut, src->shortcut, i * sizeof *dest->shortcut ); } } diff --git a/fdesign/fd_main.c b/fdesign/fd_main.c index 05b815f..9dba2fe 100644 --- a/fdesign/fd_main.c +++ b/fdesign/fd_main.c @@ -647,7 +647,7 @@ pre_connect( int argc, } else if ( strncmp( argv[ i ] + 1, "dir", 3 ) == 0 && i + 1 < argc ) { - fdopt.output_dir = malloc( strlen( argv[ ++i ] ) + 1 ); + fdopt.output_dir = fl_malloc( strlen( argv[ ++i ] ) + 1 ); strcpy( fdopt.output_dir, argv[ i ] ); } else if ( strncmp( argv[ i ] + 1, "lang", 4 ) == 0 && i + 1 < argc ) diff --git a/fdesign/fd_printC.c b/fdesign/fd_printC.c index 29ab70a..e306ed2 100644 --- a/fdesign/fd_printC.c +++ b/fdesign/fd_printC.c @@ -59,14 +59,14 @@ make_backup( const char *s ) return; } - buf = malloc( strlen( s ) + 5 ); + buf = fl_malloc( strlen( s ) + 5 ); sprintf( buf, "%s.bak", s ); #ifdef __EMX__ if ( unlink( buf ) ) { M_err( __func__, "Creating backup file %s failed", buf ); - free( buf ); + fl_free( buf ); return; } #endif @@ -75,7 +75,7 @@ make_backup( const char *s ) M_err( __func__, "Creating backup file %s failed: %s", buf, strerror( errno ) ); - free( buf ); + fl_free( buf ); } @@ -826,7 +826,7 @@ check_array_name( char * aname ) if ( anumb == MAXARNAME ) return FL_FALSE; - arnames[ anumb ] = malloc( MAX_VAR_LEN ); + arnames[ anumb ] = fl_malloc( MAX_VAR_LEN ); strcpy( arnames[ anumb ], tmpstr); arsizes[ anumb++ ] = ind + 1; return FL_TRUE; diff --git a/image/image.c b/image/image.c index 823d0f8..76c0c8a 100644 --- a/image/image.c +++ b/image/image.c @@ -1371,7 +1371,7 @@ flimage_dup_( FL_IMAGE * sim, if ( ! im ) { - flimage_error( sim,"malloc() failed in image_dup()" ); + flimage_error( sim,"fl_malloc() failed in image_dup()" ); return 0; } diff --git a/image/image_bmp.c b/image/image_bmp.c index 191da8f..95e2aa6 100644 --- a/image/image_bmp.c +++ b/image/image_bmp.c @@ -499,7 +499,7 @@ load_1bit_bmp( FL_IMAGE * im, if( ! buf ) { - im->error_message( im, "malloc() failed" ); + im->error_message( im, "fl_malloc() failed" ); return -1; } @@ -508,7 +508,7 @@ load_1bit_bmp( FL_IMAGE * im, if ( fread( buf, 1, totalbpl, im->fpin ) != ( size_t ) totalbpl ) { fl_free( buf ); - im->error_message( im, "malloc() failed" ); + im->error_message( im, "fl_malloc() failed" ); return -1; } @@ -691,7 +691,7 @@ BMP_write_image( FL_IMAGE * im ) if ( ! tmpbuf ) { - im->error_message( im, "malloc() failed" ); + im->error_message( im, "fl_malloc() failed" ); return -1; } diff --git a/image/image_disp.c b/image/image_disp.c index d3cc6eb..4ae2d0a 100644 --- a/image/image_disp.c +++ b/image/image_disp.c @@ -80,7 +80,7 @@ get_colors( Colormap colormap, if ( ! ( newpixels = fl_malloc( map_len * sizeof *newpixels ) ) ) { - M_err( __func__, "malloc failed while getting colors" ); + M_err( __func__, "fl_malloc failed while getting colors" ); return 0; } @@ -135,7 +135,7 @@ get_all_colors( FL_IMAGE * im, if ( ! mapentry ) { - M_err( __func__, "malloc failure(%d entries)", max_colors ); + M_err( __func__, "fl_malloc failure(%d entries)", max_colors ); return; } @@ -309,7 +309,7 @@ fl_display_ci( FL_IMAGE * im, { XFree( ximage ); fl_free( xpixels ); - M_err( __func__, "malloc failed" ); + M_err( __func__, "fl_malloc failed" ); return -1; } @@ -702,7 +702,7 @@ fl_display_rgb( FL_IMAGE * im, if ( ! xpixels ) { - flimage_error( im, "malloc() failed" ); + flimage_error( im, "fl_malloc() failed" ); return -1; } diff --git a/image/image_scale.c b/image/image_scale.c index 6892a8c..b1b0e6e 100644 --- a/image/image_scale.c +++ b/image/image_scale.c @@ -268,7 +268,7 @@ flimage_scale( FL_IMAGE * im, if ( err ) { - im->error_message( im, "Scale: malloc failed" ); + im->error_message( im, "Scale: fl_malloc failed" ); fl_free_matrix( nm[ 0 ]); fl_free_matrix( nm[ 1 ]); fl_free_matrix( nm[ 2 ]); diff --git a/image/image_text.c b/image/image_text.c index 70340b4..0fc6cb8 100644 --- a/image/image_text.c +++ b/image/image_text.c @@ -63,7 +63,7 @@ flimage_add_text( FL_IMAGE * im, if ( ! im->text ) { - flimage_error( im, "AddText: malloc failed" ); + flimage_error( im, "AddText: fl_malloc failed" ); return -1; } diff --git a/lib/asyn_io.c b/lib/asyn_io.c index dabc667..f60fe3f 100644 --- a/lib/asyn_io.c +++ b/lib/asyn_io.c @@ -289,7 +289,7 @@ add_to_freelist( FLI_IO_REC * io ) { struct free_list *cur; - cur = malloc( sizeof *cur ); + cur = fl_malloc( sizeof *cur ); cur->next = fl; cur->io = io; diff --git a/lib/clock.c b/lib/clock.c index ba8e8f7..2825b16 100644 --- a/lib/clock.c +++ b/lib/clock.c @@ -197,12 +197,14 @@ draw_digitalclock( FL_OBJECT * ob ) { if ( ! sp->hide_seconds ) sprintf( buf, "%d:%02d:%02d %s", - sp->hours > 12 ? sp->hours - 12 : sp->hours, - sp-> minutes, sp->seconds, sp->hours > 12 ? "pm" : "am" ); + sp->hours == 0 ? 12 : (sp->hours > 12 ? + sp->hours - 12 : sp->hours), + sp-> minutes, sp->seconds, sp->hours >= 12 ? "pm" : "am" ); else sprintf( buf, "%d:%02d %s", - sp->hours > 12 ? sp->hours - 12 : sp->hours, - sp->minutes, sp->hours > 12 ? "pm" : "am" ); + sp->hours == 0 ? 12 : (sp->hours > 12 ? + sp->hours - 12 : sp->hours), + sp->minutes, sp->hours >= 12 ? "pm" : "am" ); } else { @@ -259,8 +261,7 @@ handle_clock( FL_OBJECT * ob, case FL_STEP: /* Clock has a resolution of about 1 sec. FL_STEP is sent about - every 0.05 sec. If there are more than 10 clocks, we might run - into trouble */ + every 0.05 sec. Reduce number of tests to 10 per second. */ if ( ++sp->nstep & 1 ) break; diff --git a/lib/goodie_yesno.c b/lib/goodie_yesno.c index 59bb8c5..4d4bc56 100644 --- a/lib/goodie_yesno.c +++ b/lib/goodie_yesno.c @@ -51,7 +51,7 @@ typedef struct static FD_yesno * create_yesno( void ) { - FD_yesno *fdui = malloc( sizeof *fdui ); + FD_yesno *fdui = fl_malloc( sizeof *fdui ); int oldy = fli_inverted_y; int oldu = fl_get_coordunit( ); @@ -111,7 +111,9 @@ fl_show_question( const char * str, fl_free( fd_yesno ); } else + { fl_deactivate_all_forms( ); + } fd_yesno = create_yesno( ); diff --git a/lib/spinner.c b/lib/spinner.c index b6498f5..7b62661 100644 --- a/lib/spinner.c +++ b/lib/spinner.c @@ -275,8 +275,7 @@ spinner_callback( FL_OBJECT * obj, buf = fl_malloc( max_len ); sprintf( buf, "%d", sp->i_val ); fl_set_input( sp->input, buf ); - fl_free( buf ); - buf = NULL; + fli_safe_free( buf ); if ( data != 0 ) { @@ -329,11 +328,10 @@ spinner_callback( FL_OBJECT * obj, sp->f_val = sp->f_min; } - buf = malloc( max_len ); + buf = fl_malloc( max_len ); sprintf( buf, "%.*f", sp->prec, sp->f_val ); fl_set_input( sp->input, buf ); - fl_free( buf ); - buf = NULL; + fli_safe_free( buf ); if ( data != 0 ) { @@ -371,7 +369,7 @@ fl_create_spinner( int type, obj->boxtype = FL_NO_BOX; obj->align = FL_ALIGN_LEFT; obj->set_return = set_spinner_return; - obj->spec = sp = malloc( sizeof *sp ); + obj->spec = sp = fl_malloc( sizeof *sp ); if ( ( type == FL_INT_SPINNER ) || ( type == FL_INT_MIDDLE_SPINNER ) ) |