This is preparation for parsing mask expressions.
spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
const spv_operand_type_t type,
- const char *name,
- spv_operand_desc *pEntry) {
+ const char* name,
+ const size_t nameLength,
+ spv_operand_desc* pEntry) {
if (!table) return SPV_ERROR_INVALID_TABLE;
if (!name || !pEntry) return SPV_ERROR_INVALID_POINTER;
- const uint64_t nameLength = strlen(name);
for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
if (type == table->types[typeIndex].type) {
for (uint64_t operandIndex = 0;
if (nameLength ==
strlen(table->types[typeIndex].entries[operandIndex].name) &&
!strncmp(table->types[typeIndex].entries[operandIndex].name, name,
- strlen(name))) {
+ nameLength)) {
*pEntry = &table->types[typeIndex].entries[operandIndex];
return SPV_SUCCESS;
}
/// @param[in] table to lookup
/// @param[in] type the operand group's type
/// @param[in] name of the operand to find
+/// @param[in] nameLength number of bytes of name to compare
/// @param[out] pEntry returned operand table entry
///
/// @return result code
spv_result_t spvOperandTableNameLookup(const spv_operand_table table,
const spv_operand_type_t type,
const char *name,
+ const size_t nameLength,
spv_operand_desc *pEntry);
/// @brief Find the operand with value in the table
// NOTE: All non literal operands are handled here using the operand
// table.
spv_operand_desc entry;
- if (spvOperandTableNameLookup(operandTable, type, textValue, &entry)) {
+ if (spvOperandTableNameLookup(operandTable, type, textValue,
+ strlen(textValue), &entry)) {
DIAGNOSTIC << "Invalid " << spvOperandTypeStr(type) << " '" << textValue
<< "'.";
return SPV_ERROR_INVALID_TEXT;