Use char** instead of string

This commit is contained in:
Vo Van Nghia 2020-06-17 23:41:36 +07:00
parent 6ffd6820ff
commit 8b7af2c770
3 changed files with 3 additions and 14 deletions

View File

@ -147,14 +147,8 @@ TF_StringStream* TF_GetLocalTempDirectories() {
return list; return list;
} }
void TF_GetTempFileName(const char* extension, std::string* name, void TF_GetTempFileName(const char* extension, char** name) {
TF_Status* status) { *name = strdup(::tensorflow::io::GetTempFilename(extension).c_str());
*name = ::tensorflow::io::GetTempFilename(extension);
if (name->length() == 0) {
TF_SetStatus(status, TF_INTERNAL, "Can not get temp file name");
} else {
TF_SetStatus(status, TF_OK, "");
}
} }
TF_CAPI_EXPORT extern uint64_t TF_NowNanos(void) { TF_CAPI_EXPORT extern uint64_t TF_NowNanos(void) {

View File

@ -20,8 +20,6 @@ limitations under the License.
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string>
#include "tensorflow/c/c_api.h" #include "tensorflow/c/c_api.h"
#include "tensorflow/c/tf_file_statistics.h" #include "tensorflow/c/tf_file_statistics.h"
@ -157,8 +155,7 @@ TF_CAPI_EXPORT extern TF_StringStream* TF_GetLocalTempDirectories(void);
// Creates a temporary file name with an extension. // Creates a temporary file name with an extension.
// The caller is responsible for freeing the returned pointer. // The caller is responsible for freeing the returned pointer.
TF_CAPI_EXPORT extern void TF_GetTempFileName(const char* extension, TF_CAPI_EXPORT extern void TF_GetTempFileName(const char* extension,
std::string* name, char** name);
TF_Status* status);
// Returns the number of nanoseconds since the Unix epoch. // Returns the number of nanoseconds since the Unix epoch.
TF_CAPI_EXPORT extern uint64_t TF_NowNanos(void); TF_CAPI_EXPORT extern uint64_t TF_NowNanos(void);

View File

@ -327,8 +327,6 @@ string GetTempFilename(const string& extension) {
} }
LOG(FATAL) << "No temp directory found."; LOG(FATAL) << "No temp directory found.";
#endif #endif
// Return an empty string to indicate that we can not create temp file name.
return "";
} }
bool GetTestUndeclaredOutputsDir(string* dir) { bool GetTestUndeclaredOutputsDir(string* dir) {