Example #1
0
static int update_values( wcstring_list_t &list, 
						  std::vector<long> &indexes,
						  wcstring_list_t &values ) 
{
	size_t i;

	/* Replace values where needed */
	for( i = 0; i < indexes.size(); i++ ) 
	{
		/*
		  The '- 1' below is because the indices in fish are
		  one-based, but the vector uses zero-based indices
		*/
		long ind = indexes[i] - 1;
		const wcstring newv = values[ i ];
		if( ind < 0 )
		{
			return 1;
		}
        if ( ind >= list.size() )
        {
            list.resize( ind+1 );
        }
		
//		free((void *) al_get(list, ind));
		list[ ind ] = newv; 
	}
  
	return 0;
}
Example #2
0
static int update_values(wcstring_list_t &list, std::vector<long> &indexes,
                         wcstring_list_t &values) {
    // Replace values where needed.
    for (size_t i = 0; i < indexes.size(); i++) {
        // The '- 1' below is because the indices in fish are one-based, but the vector uses
        // zero-based indices.
        long ind = indexes[i] - 1;
        const wcstring newv = values[i];
        if (ind < 0) {
            return 1;
        }
        if ((size_t)ind >= list.size()) {
            list.resize(ind + 1);
        }

        list[ind] = newv;
    }

    return 0;
}