| 2423 | } |
| 2424 | |
| 2425 | Object::FieldType *Object::Insert(name_t name, index_t at) |
| 2426 | // Inserts a single field with the given key at the given offset. |
| 2427 | // Caller must ensure 'at' is the correct offset for this key. |
| 2428 | { |
| 2429 | if (mFields.Length() == mFields.Capacity() && !Expand() // Attempt to expand if at capacity. |
| 2430 | || !(name = _tcsdup(name))) // Attempt to duplicate key-string. |
| 2431 | { // Out of memory. |
| 2432 | return nullptr; |
| 2433 | } |
| 2434 | // There is now definitely room in mFields for a new field. |
| 2435 | FieldType &field = *mFields.InsertUninitialized(at, 1); |
| 2436 | field.key_c = ctolower(*name); |
| 2437 | field.name = name; // Above has already copied string or called key.p->AddRef() as appropriate. |
| 2438 | field.Minit(); // Initialize to default value. Caller will likely reassign. |
| 2439 | return &field; |
| 2440 | } |
| 2441 | |
| 2442 | Map::Pair *Map::Insert(SymbolType key_type, Key key, index_t at) |
| 2443 | // Inserts a single item with the given key at the given offset. |