Commit 95eaa352 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Change internal interface to not copy string.

* The only user immediately destroyd the copy.
parent 91c4346e
......@@ -119,9 +119,9 @@ int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSiz
return CDI_NOERR;
}
char* cdiInputFile_copyPath(const CdiInputFile* me)
const char* cdiInputFile_getPath(const CdiInputFile* me)
{
return myStrDup(me->path);
return me->path;
}
void cdiInputFile_destruct(CdiInputFile* me)
......
......@@ -21,7 +21,9 @@ typedef struct CdiInputFile {
//Final class, the constructor is private and not defined here.
CdiInputFile* cdiInputFile_make(const char* path); //The caller is responsible to call cdiRefObject_release() on the returned object.
int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer); //Returns one of CDI_EINVAL, CDI_ESYSTEM, CDI_EEOF, OR CDI_NOERR.
char* cdiInputFile_copyPath(const CdiInputFile* me); //Returns a malloc'ed string, don't forget to free() it.
/* Returns path string, don't use after destruction of CdiInputFile
* object */
const char* cdiInputFile_getPath(const CdiInputFile* me);
//Destructor is private as well.
#endif
......@@ -120,9 +120,8 @@ char* cdiGribIterator_serialize(CdiIterator* super)
{
CdiGribIterator* me = (CdiGribIterator*)super;
char* path = cdiInputFile_copyPath(me->file);
const char* path = cdiInputFile_getPath(me->file);
char* escapedPath = cdiEscapeSpaces(path);
free(path);
char* result = myAsprintf("%s %zu", escapedPath, me->fileOffset);
free(escapedPath);
return result;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment