diff options
author | Jason Sams <jsams@google.com> | 2015-05-19 19:51:26 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-19 19:51:26 +0000 |
commit | 9a6bbddf6c9cc9ff8c9092bbc4f915d4afdbda34 (patch) | |
tree | 186eea2194063e10454d8e576fb3f3302f92cd45 | |
parent | e989da4557767e87f2199b81170c9af7c97df41b (diff) | |
parent | 867ce7f7985175e77f679141b698c474bd52b4c1 (diff) | |
download | rs-9a6bbddf6c9cc9ff8c9092bbc4f915d4afdbda34.tar.gz |
Merge "Fix cache path initialization and set." into mnc-dev
-rw-r--r-- | rsContext.cpp | 18 | ||||
-rw-r--r-- | rsContext.h | 17 |
2 files changed, 24 insertions, 11 deletions
diff --git a/rsContext.cpp b/rsContext.cpp index 29b4036f..fba06cd9 100644 --- a/rsContext.cpp +++ b/rsContext.cpp @@ -459,8 +459,26 @@ Context::Context() { mContextType = RS_CONTEXT_TYPE_NORMAL; mSynchronous = false; mFatalErrorOccured = false; + + memset(mCacheDir, 0, sizeof(mCacheDir)); +#ifdef RS_COMPATIBILITY_LIB + memset(nativeLibDir, 0, sizeof(nativeLibDir)); +#endif } +void Context::setCacheDir(const char * cacheDir_arg, uint32_t length) { + if (!hasSetCacheDir) { + if (length <= PATH_MAX) { + memcpy(mCacheDir, cacheDir_arg, length); + mCacheDir[length] = 0; + hasSetCacheDir = true; + } else { + setError(RS_ERROR_BAD_VALUE, "Invalid path"); + } + } +} + + Context * Context::createContext(Device *dev, const RsSurfaceConfig *sc, RsContextType ct, uint32_t flags) { Context * rsc = new Context(); diff --git a/rsContext.h b/rsContext.h index 6cb0ed76..c6b70797 100644 --- a/rsContext.h +++ b/rsContext.h @@ -258,6 +258,7 @@ public: if (!hasSetNativeLibDir) { if (length <= PATH_MAX) { memcpy(nativeLibDir, libDir, length); + nativeLibDir[length] = 0; hasSetNativeLibDir = true; } else { setError(RS_ERROR_BAD_VALUE, "Invalid path"); @@ -269,18 +270,12 @@ public: } #endif - void setCacheDir(const char * cacheDir_arg, uint32_t length) { - if (!hasSetCacheDir) { - if (length <= PATH_MAX) { - memcpy(mCacheDir, cacheDir_arg, length); - hasSetCacheDir = true; - } else { - setError(RS_ERROR_BAD_VALUE, "Invalid path"); - } - } - } + void setCacheDir(const char * cacheDir_arg, uint32_t length); const char * getCacheDir() { - return mCacheDir; + if (hasSetCacheDir) { + return mCacheDir; + } + return nullptr; } // Returns the actual loaded driver's name (like "libRSDriver.so"). |