@@ -633,8 +633,6 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
633633 int idx_c_len = 0 ;
634634 float value_f = 0.0 ;
635635 float resolution = 0.1f ;
636- char * value_c = NULL ;
637- int value_c_len = 0 ;
638636
639637 struct object_data * pObject ;
640638 /* Valid data? */
@@ -678,12 +676,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
678676 value .type .Real , wp_data -> priority ,
679677 & wp_data -> error_class , & wp_data -> error_code )) {
680678 value_f = Analog_Present_Value (pObject );
681- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
682- value_c = malloc (value_c_len + 1 );
683- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
684- ucix_add_option (ctxw , sec , idx_c , "value" , value_c );
679+ ucix_add_option_float (ctxw , sec , idx_c , "value" ,
680+ value_f , resolution );
685681 ucix_commit (ctxw ,sec );
686- free (value_c );
687682 }
688683 } else {
689684 status = write_property_type_valid (wp_data , & value ,
@@ -693,12 +688,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
693688 pObject , wp_data -> priority ,
694689 & wp_data -> error_class , & wp_data -> error_code )) {
695690 value_f = Analog_Present_Value (pObject );
696- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
697- value_c = malloc (value_c_len + 1 );
698- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
699- ucix_add_option (ctxw , sec , idx_c , "value" , value_c );
691+ ucix_add_option_float (ctxw , sec , idx_c , "value" ,
692+ value_f , resolution );
700693 ucix_commit (ctxw ,sec );
701- free (value_c );
702694 }
703695 }
704696 }
@@ -727,13 +719,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
727719 if (status ) {
728720 Analog_COV_Increment_Set (pObject ,
729721 value .type .Real );
730- value_f = pObject -> COV_Increment ;
731- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
732- value_c = malloc (value_c_len + 1 );
733- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
734- ucix_add_option (ctxw , sec , idx_c , "cov_increment" , value_c );
722+ ucix_add_option_float (ctxw , sec , idx_c , "cov_increment" ,
723+ pObject -> COV_Increment , resolution );
735724 ucix_commit (ctxw ,sec );
736- free (value_c );
737725 }
738726 break ;
739727 case PROP_OBJECT_IDENTIFIER :
@@ -746,9 +734,10 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
746734 BACNET_APPLICATION_TAG_CHARACTER_STRING );
747735 if (status ) {
748736 if (Analog_Name_Set (
749- pObject , value .type .Character_String .value , Object_Type , wp_data -> object_instance )) {
737+ pObject , value .type .Character_String .value ,
738+ Object_Type , wp_data -> object_instance )) {
750739 ucix_add_option (ctxw , sec , idx_c , "name" ,
751- strndup ( value .type .Character_String . value , value . type . Character_String . length ));
740+ characterstring_value_const ( & value .type .Character_String ));
752741 ucix_commit (ctxw ,sec );
753742 }
754743 }
@@ -782,13 +771,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
782771 if (status ) {
783772 if (Analog_Max_Pres_Value_Set (pObject ,
784773 value .type .Real )) {
785- value_f = pObject -> Max_Pres_Value ;
786- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
787- value_c = malloc (value_c_len + 1 );
788- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
789- ucix_add_option (ctxw , sec , idx_c , "max_value" , value_c );
774+ ucix_add_option_float (ctxw , sec , idx_c , "max_value" ,
775+ pObject -> Max_Pres_Value , resolution );
790776 ucix_commit (ctxw ,sec );
791- free (value_c );
792777 }
793778 }
794779 break ;
@@ -798,13 +783,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
798783 if (status ) {
799784 if (Analog_Min_Pres_Value_Set (pObject ,
800785 value .type .Real )) {
801- value_f = pObject -> Min_Pres_Value ;
802- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
803- value_c = malloc (value_c_len + 1 );
804- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
805- ucix_add_option (ctxw , sec , idx_c , "min_value" , value_c );
786+ ucix_add_option_float (ctxw , sec , idx_c , "min_value" ,
787+ pObject -> Min_Pres_Value , resolution );
806788 ucix_commit (ctxw ,sec );
807- free (value_c );
808789 }
809790 }
810791 break ;
@@ -813,13 +794,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
813794 BACNET_APPLICATION_TAG_REAL );
814795 if (status ) {
815796 pObject -> Resolution = value .type .Real ;
816- value_f = pObject -> Resolution ;
817- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
818- value_c = malloc (value_c_len + 1 );
819- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
820- ucix_add_option (ctxw , sec , idx_c , "resolution" , value_c );
797+ ucix_add_option_float (ctxw , sec , idx_c , "resolution" ,
798+ pObject -> Resolution , 0 );
821799 ucix_commit (ctxw ,sec );
822- free (value_c );
823800 }
824801 break ;
825802 case PROP_DESCRIPTION :
@@ -866,12 +843,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
866843 if (Analog_High_Limit_Set (pObject ,
867844 value .type .Real )) {
868845 value_f = pObject -> High_Limit ;
869- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
870- value_c = malloc (value_c_len + 1 );
871- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
872- ucix_add_option (ctxw , sec , idx_c , "high_limit" , value_c );
846+ ucix_add_option_float (ctxw , sec , idx_c , "high_limit" ,
847+ pObject -> High_Limit , resolution );
873848 ucix_commit (ctxw ,sec );
874- free (value_c );
875849 }
876850 }
877851 break ;
@@ -881,13 +855,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
881855 if (status ) {
882856 if (Analog_Low_Limit_Set (pObject ,
883857 value .type .Real )) {
884- value_f = pObject -> Low_Limit ;
885- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
886- value_c = malloc (value_c_len + 1 );
887- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
888- ucix_add_option (ctxw , sec , idx_c , "low_limit" , value_c );
858+ ucix_add_option_float (ctxw , sec , idx_c , "low_limit" ,
859+ pObject -> Low_Limit , resolution );
889860 ucix_commit (ctxw ,sec );
890- free (value_c );
891861 }
892862 }
893863 break ;
@@ -897,13 +867,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
897867 if (status ) {
898868 if (Analog_Deadband_Set (pObject ,
899869 value .type .Real )) {
900- value_f = pObject -> Deadband ;
901- value_c_len = snprintf_res (NULL , 0 , resolution , value_f );
902- value_c = malloc (value_c_len + 1 );
903- snprintf_res (value_c , value_c_len + 1 , resolution , value_f );
904- ucix_add_option (ctxw , sec , idx_c , "dead_limit" , value_c );
870+ ucix_add_option_float (ctxw , sec , idx_c , "dead_limit" ,
871+ pObject -> Deadband , resolution );
905872 ucix_commit (ctxw ,sec );
906- free (value_c );
907873 }
908874 }
909875 break ;
0 commit comments