Skip to content

Commit

Permalink
avoid duplicatge entry addition.
Browse files Browse the repository at this point in the history
  • Loading branch information
msmeissn committed Oct 21, 2024
1 parent b2f2052 commit 9e01719
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libgphoto2/gphoto2-widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,16 @@ gp_widget_get_range (CameraWidget *range, float *min, float *max,
int
gp_widget_add_choice (CameraWidget *widget, const char *choice)
{
int i;

C_PARAMS (widget && choice);
C_PARAMS ((widget->type == GP_WIDGET_RADIO) ||
(widget->type == GP_WIDGET_MENU));

for (i=0;i<widget->choice_count;i++)
if (!strcmp(widget->choice[i],choice))
return GP_OK;

C_MEM (widget->choice = realloc (widget->choice, sizeof(char*)*(widget->choice_count+1)));
C_MEM (widget->choice[widget->choice_count] = strdup(choice));
widget->choice_count += 1;
Expand Down

0 comments on commit 9e01719

Please sign in to comment.