- for( i = 0; i < p_input->p->i_bookmark; i++ )
- {
- sprintf( psz_next, "{name=%s,bytes=%"PRId64",time=%"PRId64"}",
- p_input->p->pp_bookmark[i]->psz_name,
- p_input->p->pp_bookmark[i]->i_byte_offset,
- p_input->p->pp_bookmark[i]->i_time_offset/1000000 );
-
- psz_next += strlen( psz_next );
- if( i < p_input->p->i_bookmark - 1)
- *psz_next = ','; psz_next++;
- }
+ val.i_int = i;
+ text.psz_string = p_input->p->pp_bookmark[i]->psz_name;
+ var_Change( p_input, "bookmark", VLC_VAR_ADDCHOICE,
+ &val, &text );
+ }
+
+ /* Create the "bookmarks" option value */
+ const char *psz_format = "{name=%s,bytes=%"PRId64",time=%"PRId64"}";
+ int i_len = strlen( "bookmarks=" );
+ for( int i = 0; i < p_input->p->i_bookmark; i++ )
+ {
+ const seekpoint_t *p_bookmark = p_input->p->pp_bookmark[i];
+
+ i_len += snprintf( NULL, 0, psz_format,
+ p_bookmark->psz_name,
+ p_bookmark->i_byte_offset,
+ p_bookmark->i_time_offset/1000000 );
+ }
+
+ char *psz_value = malloc( i_len + p_input->p->i_bookmark + 1 );
+ char *psz_next = psz_value;
+
+ psz_next += sprintf( psz_next, "bookmarks=" );
+ for( int i = 0; i < p_input->p->i_bookmark && psz_value != NULL; i++ )
+ {
+ const seekpoint_t *p_bookmark = p_input->p->pp_bookmark[i];
+
+ psz_next += sprintf( psz_next, psz_format,
+ p_bookmark->psz_name,
+ p_bookmark->i_byte_offset,
+ p_bookmark->i_time_offset/1000000 );
+
+ if( i < p_input->p->i_bookmark - 1)
+ *psz_next++ = ',';