On Tue, Oct 19, 2010 at 10:26 AM, Lucas De Marchi <lucas.demar...@profusion.mobi> wrote: > On Tue, Oct 19, 2010 at 10:19 AM, Gustavo Sverzut Barbieri > <barbi...@profusion.mobi> wrote: >> This seems good, but would it handle the following cases? >> >> 1. >> >> void name_set(struct my_struct *p, const char *name) { >> eina_stringshare_replace(&p->str, name); // could be a simple >> eina_stringshare_add() as well >> } >> const char *name_get(const struct my_struct *p) { >> return p->str; >> } >> Eina_Bool use_it(const struct my_struct *p) { >> return strlen(p->str) % 2; // should be eina_stringshare_strlen() >> } >> > > As I told, right now it will not handle this case. But it can be > extended to do so.
then it will not handle most of our cases :-/ Actually if it's in the form: const char *s = eina_stringshare_add(bla); size_t len = eina_stringshare_strlen(s); it's better (minimal performance gains) to write it like: size_t len = strlen(bla); // if you know it's !NULL const char *s = eina_stringshare_add_length(bla, len); as internally eina_stringshare_add_length() will be called by eina_stringshare_add(), and strlen() is often optimized by the compiler if possible (ie: instead of bla you have "string" it turns it into sizeof("string")-1). >> 2. >> Eina_Bool use_it(const char *s) { >> return strlen(x) % 2; // should not be eina_stringshare_strlen() >> } >> >> use_it(name_get(p)); >> use_it("hello"); > > If you meant "return strlen(s) % 2", yes, this would not be changed. typos :-D that's why we should not write programs in MS word kids! ;-) -- Gustavo Sverzut Barbieri http://profusion.mobi embedded systems -------------------------------------- MSN: barbi...@gmail.com Skype: gsbarbieri Mobile: +55 (19) 9225-2202 ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel