------------------------------------------------------------------------- RecGetRecord_Xmalloc -------------------------------------------------------------------------
| 767 | // RecGetRecord_Xmalloc |
| 768 | //------------------------------------------------------------------------- |
| 769 | RecErrT |
| 770 | RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data, bool lock) |
| 771 | { |
| 772 | RecErrT err = REC_ERR_OKAY; |
| 773 | |
| 774 | if (lock) { |
| 775 | ink_rwlock_rdlock(&g_records_rwlock); |
| 776 | } |
| 777 | |
| 778 | if (auto it = g_records_ht.find(name); it != g_records_ht.end()) { |
| 779 | RecRecord *r = it->second; |
| 780 | |
| 781 | rec_mutex_acquire(&(r->lock)); |
| 782 | if (!r->registered || (r->data_type != data_type)) { |
| 783 | err = REC_ERR_FAIL; |
| 784 | } else { |
| 785 | // Clear the caller's record just in case it has trash in it. |
| 786 | // Passing trashy records to RecDataSet will cause confusion. |
| 787 | memset(data, 0, sizeof(RecData)); |
| 788 | RecDataSet(data_type, data, &(r->data)); |
| 789 | } |
| 790 | rec_mutex_release(&(r->lock)); |
| 791 | } else { |
| 792 | err = REC_ERR_FAIL; |
| 793 | } |
| 794 | |
| 795 | if (lock) { |
| 796 | ink_rwlock_unlock(&g_records_rwlock); |
| 797 | } |
| 798 | |
| 799 | return err; |
| 800 | } |
| 801 | |
| 802 | //------------------------------------------------------------------------- |
| 803 | // RecForceInsert |
no test coverage detected