Skip to content

Commit

Permalink
free-malloc -> realloc
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfriedt committed Aug 18, 2019
1 parent 8e303e6 commit 3127c19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/oscilloscope_impl.cc
Expand Up @@ -302,6 +302,12 @@ void oscilloscope_impl::set_duration(float duration)
else
_sample_size = 8192;
printf("_sample_size=%d\n",_sample_size);
_data_buffer=(char*)realloc(_data_buffer,2*_sample_size+100);
_tab1=(float*)realloc(_tab1,_sample_size*sizeof(float));
_tab2=(float*)realloc(_tab2,_sample_size*sizeof(float));
_tab3=(float*)realloc(_tab3,_sample_size*sizeof(float));
_tab4=(float*)realloc(_tab4,_sample_size*sizeof(float));
/*
if (_data_buffer!=NULL)
{free(_data_buffer);
free(_tab1);
Expand All @@ -314,6 +320,7 @@ void oscilloscope_impl::set_duration(float duration)
_tab2=(float*)malloc(_sample_size*sizeof(float));
_tab3=(float*)malloc(_sample_size*sizeof(float));
_tab4=(float*)malloc(_sample_size*sizeof(float));
*/
_duration=duration;
}

Expand Down Expand Up @@ -359,6 +366,12 @@ void oscilloscope_impl::set_rate(float rate)
else
_sample_size = 8192;
printf("_sample_size=%d\n",_sample_size);
_data_buffer=(char*)realloc(_data_buffer,2*_sample_size+100);
_tab1=(float*)realloc(_tab1,_sample_size*sizeof(float));
_tab2=(float*)realloc(_tab2,_sample_size*sizeof(float));
_tab3=(float*)realloc(_tab3,_sample_size*sizeof(float));
_tab4=(float*)realloc(_tab4,_sample_size*sizeof(float));
/*
if (_data_buffer!=NULL)
{free(_data_buffer);
free(_tab1);
Expand All @@ -371,6 +384,7 @@ void oscilloscope_impl::set_rate(float rate)
_tab2=(float*)malloc(_sample_size*sizeof(float));
_tab3=(float*)malloc(_sample_size*sizeof(float));
_tab4=(float*)malloc(_sample_size*sizeof(float));
*/
_rate=rate;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/oscilloscope_impl.h
Expand Up @@ -49,7 +49,7 @@ namespace gr {
int longueur,result;
// #endif
float _range,_duration,_rate;
float *_tab1,*_tab2,*_tab3,*_tab4;
float *_tab1=NULL,*_tab2=NULL,*_tab3=NULL,*_tab4=NULL;
int _sample_size;
char device_ip[16]; // IP @
char *_data_buffer=NULL;
Expand Down

0 comments on commit 3127c19

Please sign in to comment.