int sh_hash_t::insert(uint64_t ddwKey, char *pValue, uint32_t dwValueLen) { sh_ptr_t<sh_hash_node_t> pNode = sh_malloc(sizeof(sh_hash_node_t), 0); pNode->ddwKey = ddwKey; pNode->pValue = sh_malloc(dwValueLen, 0); memcpy((char*)pNode->pValue, pValue, dwValueLen); pNode->dwValueLen = dwValueLen; uint32_t dwMod = ddwKey % m_dwHashSize; pNode->pNext = m_buckets[dwMod]; m_buckets[dwMod] = pNode; return 0; }
int sh_hash_t::init(int hash_size) { m_dwHashSize = hash_size; m_buckets = sh_malloc(m_dwHashSize * sizeof(sh_ptr_t<sh_hash_node_t>), 0); if (m_buckets == sh_null) { return -__LINE__; } return 0; }
void *CRYPTO_secure_malloc(size_t num, const char *file, int line) { #ifdef IMPLEMENTED void *ret; size_t actual_size; if (!secure_mem_initialized) { return CRYPTO_malloc(num, file, line); } CRYPTO_THREAD_write_lock(sec_malloc_lock); ret = sh_malloc(num); actual_size = ret ? sh_actual_size(ret) : 0; secure_mem_used += actual_size; CRYPTO_THREAD_unlock(sec_malloc_lock); return ret; #else return CRYPTO_malloc(num, file, line); #endif /* IMPLEMENTED */ }
void *CRYPTO_secure_malloc(int num, const char *file, int line) { #ifdef IMPLEMENTED void *ret; size_t actual_size; if (!secure_mem_initialized) { too_late = 1; return CRYPTO_malloc(num, file, line); } LOCK(); ret = sh_malloc(num); actual_size = ret ? sh_actual_size(ret) : 0; secure_mem_used += actual_size; UNLOCK(); return ret; #else return CRYPTO_malloc(num, file, line); #endif /* IMPLEMENTED */ }