Page MenuHomePhabricator

eina: Handling failure scenarios of strbuf_substr_get.

Authored by sri.hebbar on Dec 16 2015, 10:27 PM.



Fixes T2949

Signed-off-by: Srivardhan Hebbar <>

Diff Detail

rEFL core/efl
No Linters Available
No Unit Test Coverage
Build Status
Buildable 984
Build 1049: arc lint + arc unit
sri.hebbar retitled this revision from to eina: Handling failure scenarios of strbuf_substr_get..
sri.hebbar updated this object.
sri.hebbar edited the test plan for this revision. (Show Details)
sri.hebbar added reviewers: cedric, jpeg.
jpeg requested changes to this revision.Dec 30 2015, 8:41 PM
jpeg edited edge metadata.

This is changing behaviour.
Before the patch, len = 0 returns "" (packed inside an strbuf).
Now, it returns NULL.

I'm not sure this is the best way to do. Example:

str2 = substr(str1, idx1 - idx2);
strbuf_append(str2, "bla bla")

This pseudo-code should always work, even if idx1 == idx2. With your patch it wont work anymore.

This revision now requires changes to proceed.Dec 30 2015, 8:41 PM
sri.hebbar edited edge metadata.

Yeah... If len is zero, then str would be allocated just one byte. The
last byte should be set to NULL. So updated the patch.

cedric requested changes to this revision.Jan 4 2016, 2:29 PM
cedric edited edge metadata.
cedric added inline comments.

What is the point of setting it to '\0' here ? It has been calloced. It makes sense to just malloc + '\0' + strncpy, but not to do that with calloc in my opinion.

This revision now requires changes to proceed.Jan 4 2016, 2:29 PM
sri.hebbar abandoned this revision.Jan 6 2016, 9:09 PM

Actually, this patch itself is not needed. The API is fine, only the test case need to modified. So abandoning this patch.