소스 검색

Merge pull request #313 from WeebDataHoarder/cache-memory-api

Added `randomx_get_cache_memory` API
SChernykh 1 년 전
부모
커밋
10494476d6
2개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      src/randomx.cpp
  2. 10 0
      src/randomx.h

+ 5 - 0
src/randomx.cpp

@@ -138,6 +138,11 @@ extern "C" {
 		}
 	}
 
+	void *randomx_get_cache_memory(randomx_cache *cache) {
+		assert(cache != nullptr);
+		return cache->memory;
+	}
+
 	void randomx_release_cache(randomx_cache* cache) {
 		assert(cache != nullptr);
 		cache->dealloc(cache);

+ 10 - 0
src/randomx.h

@@ -119,6 +119,16 @@ RANDOMX_EXPORT randomx_cache *randomx_alloc_cache(randomx_flags flags);
 */
 RANDOMX_EXPORT void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize);
 
+/**
+ * Returns a pointer to the internal memory buffer of the cache structure. The size
+ * of the internal memory buffer is RANDOMX_ARGON_MEMORY KiB.
+ *
+ * @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL.
+ *
+ * @return Pointer to the internal memory buffer of the cache structure.
+*/
+RANDOMX_EXPORT void *randomx_get_cache_memory(randomx_cache *cache);
+
 /**
  * Releases all memory occupied by the randomx_cache structure.
  *