| 356 | } |
| 357 | |
| 358 | txID fxNewNameC(txMachine* the, txString theString) |
| 359 | { |
| 360 | txU1* string; |
| 361 | txU4 sum; |
| 362 | txU4 modulo; |
| 363 | txSlot* result; |
| 364 | |
| 365 | string = (txU1*)theString; |
| 366 | sum = 0; |
| 367 | while(c_read8(string) != 0) { |
| 368 | sum = (sum << 1) + c_read8(string++); |
| 369 | } |
| 370 | sum &= 0x7FFFFFFF; |
| 371 | modulo = sum % the->nameModulo; |
| 372 | result = the->nameTable[modulo]; |
| 373 | while (result != C_NULL) { |
| 374 | if (result->value.key.sum == sum) { |
| 375 | if (c_strcmp(result->value.key.string, theString) == 0) { |
| 376 | txID id = mxGetKeySlotID(result); |
| 377 | if (id >= the->keyOffset) |
| 378 | result->flag |= XS_DONT_DELETE_FLAG; |
| 379 | return id; |
| 380 | } |
| 381 | } |
| 382 | result = result->next; |
| 383 | } |
| 384 | result = fxFindKey(the); |
| 385 | result->next = the->nameTable[modulo]; |
| 386 | result->flag = XS_INTERNAL_FLAG | XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG; |
| 387 | result->kind = XS_KEY_KIND; |
| 388 | result->value.key.string = C_NULL; |
| 389 | result->value.key.sum = sum; |
| 390 | the->nameTable[modulo] = result; |
| 391 | result->value.key.string = (txString)fxNewChunk(the, mxStringLength(theString) + 1); |
| 392 | c_strcpy(result->value.key.string, theString); |
| 393 | return result->ID; |
| 394 | } |
| 395 | |
| 396 | txID fxNewNameX(txMachine* the, txString theString) |
| 397 | { |
no test coverage detected