summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2012-01-31 17:27:57 +0000
committerTom Hacohen <tom@stosb.com>2012-01-31 17:27:57 +0000
commit518424907e448241acd37dc49918ff5ed648c752 (patch)
tree91364f63fb15edc4a3e53df3a4466e7484310b7d
parentade018086c8d236eff3ed0b366c1df16524885aa (diff)
Eina stringshare: fixed up the previous commit a bit.
Fixed wrong usage of Eina_Stringshare - Thanks k-s. Omited the star from the typedef - Thanks Sacihel. SVN revision: 67642
Diffstat (limited to '')
-rw-r--r--legacy/eina/ChangeLog2
-rw-r--r--legacy/eina/src/include/eina_inline_stringshare.x4
-rw-r--r--legacy/eina/src/include/eina_stringshare.h22
-rw-r--r--legacy/eina/src/lib/eina_stringshare.c22
4 files changed, 25 insertions, 25 deletions
diff --git a/legacy/eina/ChangeLog b/legacy/eina/ChangeLog
index 45c666e165..9372b9ce31 100644
--- a/legacy/eina/ChangeLog
+++ b/legacy/eina/ChangeLog
@@ -214,7 +214,7 @@
214 214
2152012-01-31 Tom Hacohen 2152012-01-31 Tom Hacohen
216 216
217 * Added an Eina_Stringshare type. It's just a typedef of "const char *" 217 * Added an Eina_Stringshare type. It's just a typedef of "const char"
218 this is a same kind of visual hint for the purpose of the pointer, 218 this is a same kind of visual hint for the purpose of the pointer,
219 but again, the two types are interchangeable. 219 but again, the two types are interchangeable.
220 220
diff --git a/legacy/eina/src/include/eina_inline_stringshare.x b/legacy/eina/src/include/eina_inline_stringshare.x
index 6396a74e40..19827c5552 100644
--- a/legacy/eina/src/include/eina_inline_stringshare.x
+++ b/legacy/eina/src/include/eina_inline_stringshare.x
@@ -43,7 +43,7 @@
43 * #EINA_FALSE if the strings were the same after shared. 43 * #EINA_FALSE if the strings were the same after shared.
44 */ 44 */
45static inline Eina_Bool 45static inline Eina_Bool
46eina_stringshare_replace(Eina_Stringshare *p_str, Eina_Stringshare news) 46eina_stringshare_replace(Eina_Stringshare **p_str, const char *news)
47{ 47{
48 if (*p_str == news) return EINA_FALSE; 48 if (*p_str == news) return EINA_FALSE;
49 49
@@ -72,7 +72,7 @@ eina_stringshare_replace(Eina_Stringshare *p_str, Eina_Stringshare news)
72 * #EINA_FALSE if the strings were the same after shared. 72 * #EINA_FALSE if the strings were the same after shared.
73 */ 73 */
74static inline Eina_Bool 74static inline Eina_Bool
75eina_stringshare_replace_length(Eina_Stringshare *p_str, Eina_Stringshare news, unsigned int slen) 75eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen)
76{ 76{
77 if (*p_str == news) return EINA_FALSE; 77 if (*p_str == news) return EINA_FALSE;
78 78
diff --git a/legacy/eina/src/include/eina_stringshare.h b/legacy/eina/src/include/eina_stringshare.h
index d57235971d..934fb40bc6 100644
--- a/legacy/eina/src/include/eina_stringshare.h
+++ b/legacy/eina/src/include/eina_stringshare.h
@@ -156,7 +156,7 @@
156 * 156 *
157 * @since 1.2.0 157 * @since 1.2.0
158 */ 158 */
159typedef const char * Eina_Stringshare; 159typedef const char Eina_Stringshare;
160 160
161/** 161/**
162 * @brief Retrieve an instance of a string for use in a program. 162 * @brief Retrieve an instance of a string for use in a program.
@@ -177,7 +177,7 @@ typedef const char * Eina_Stringshare;
177 * 177 *
178 * @see eina_share_common_add() 178 * @see eina_share_common_add()
179 */ 179 */
180EAPI Eina_Stringshare eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT; 180EAPI Eina_Stringshare *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
181 181
182/** 182/**
183 * @brief Retrieve an instance of a string for use in a program. 183 * @brief Retrieve an instance of a string for use in a program.
@@ -197,7 +197,7 @@ EAPI Eina_Stringshare eina_stringshare_add_length(const char *str, unsigned in
197 * 197 *
198 * @see eina_stringshare_add_length() 198 * @see eina_stringshare_add_length()
199 */ 199 */
200EAPI Eina_Stringshare eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT; 200EAPI Eina_Stringshare *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
201 201
202/** 202/**
203 * @brief Retrieve an instance of a string for use in a program 203 * @brief Retrieve an instance of a string for use in a program
@@ -218,7 +218,7 @@ EAPI Eina_Stringshare eina_stringshare_add(const char *str) EINA_WARN_UNUSED_R
218 * 218 *
219 * @see eina_stringshare_nprintf() 219 * @see eina_stringshare_nprintf()
220 */ 220 */
221EAPI Eina_Stringshare eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2); 221EAPI Eina_Stringshare *eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
222 222
223/** 223/**
224 * @brief Retrieve an instance of a string for use in a program 224 * @brief Retrieve an instance of a string for use in a program
@@ -240,7 +240,7 @@ EAPI Eina_Stringshare eina_stringshare_printf(const char *fmt, ...) EINA_WARN_
240 * 240 *
241 * @see eina_stringshare_nprintf() 241 * @see eina_stringshare_nprintf()
242 */ 242 */
243EAPI Eina_Stringshare eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT; 243EAPI Eina_Stringshare *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
244 244
245/** 245/**
246 * @brief Retrieve an instance of a string for use in a program 246 * @brief Retrieve an instance of a string for use in a program
@@ -260,7 +260,7 @@ EAPI Eina_Stringshare eina_stringshare_vprintf(const char *fmt, va_list args)
260 * 260 *
261 * @see eina_stringshare_printf() 261 * @see eina_stringshare_printf()
262 */ 262 */
263EAPI Eina_Stringshare eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3); 263EAPI Eina_Stringshare *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
264 264
265/** 265/**
266 * Increment references of the given shared string. 266 * Increment references of the given shared string.
@@ -276,7 +276,7 @@ EAPI Eina_Stringshare eina_stringshare_nprintf(unsigned int len, const char *f
276 * 276 *
277 * There is no unref since this is the work of eina_share_common_del(). 277 * There is no unref since this is the work of eina_share_common_del().
278 */ 278 */
279EAPI Eina_Stringshare eina_stringshare_ref(Eina_Stringshare str); 279EAPI Eina_Stringshare *eina_stringshare_ref(Eina_Stringshare *str);
280 280
281/** 281/**
282 * @brief Note that the given string has lost an instance. 282 * @brief Note that the given string has lost an instance.
@@ -291,7 +291,7 @@ EAPI Eina_Stringshare eina_stringshare_ref(Eina_Stringshare str);
291 * Note that if the given pointer is not shared or NULL, bad things 291 * Note that if the given pointer is not shared or NULL, bad things
292 * will happen, likely a segmentation fault. 292 * will happen, likely a segmentation fault.
293 */ 293 */
294EAPI void eina_stringshare_del(Eina_Stringshare str); 294EAPI void eina_stringshare_del(Eina_Stringshare *str);
295 295
296/** 296/**
297 * @brief Note that the given string @b must be shared. 297 * @brief Note that the given string @b must be shared.
@@ -305,7 +305,7 @@ EAPI void eina_stringshare_del(Eina_Stringshare str);
305 * things will happen, likely a segmentation fault. If in doubt, try 305 * things will happen, likely a segmentation fault. If in doubt, try
306 * strlen(). 306 * strlen().
307 */ 307 */
308EAPI int eina_stringshare_strlen(Eina_Stringshare str) EINA_PURE EINA_WARN_UNUSED_RESULT; 308EAPI int eina_stringshare_strlen(Eina_Stringshare *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
309 309
310/** 310/**
311 * @brief Dump the contents of the share_common. 311 * @brief Dump the contents of the share_common.
@@ -315,8 +315,8 @@ EAPI int eina_stringshare_strlen(Eina_Stringshare str) EINA_PURE
315 */ 315 */
316EAPI void eina_stringshare_dump(void); 316EAPI void eina_stringshare_dump(void);
317 317
318static inline Eina_Bool eina_stringshare_replace(Eina_Stringshare *p_str, Eina_Stringshare news) EINA_ARG_NONNULL(1); 318static inline Eina_Bool eina_stringshare_replace(Eina_Stringshare **p_str, const char *news) EINA_ARG_NONNULL(1);
319static inline Eina_Bool eina_stringshare_replace_length(Eina_Stringshare *p_str, Eina_Stringshare news, unsigned int slen) EINA_ARG_NONNULL(1); 319static inline Eina_Bool eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
320 320
321#include "eina_inline_stringshare.x" 321#include "eina_inline_stringshare.x"
322 322
diff --git a/legacy/eina/src/lib/eina_stringshare.c b/legacy/eina/src/lib/eina_stringshare.c
index b70ca3bd28..fe35954be9 100644
--- a/legacy/eina/src/lib/eina_stringshare.c
+++ b/legacy/eina/src/lib/eina_stringshare.c
@@ -577,7 +577,7 @@ eina_stringshare_shutdown(void)
577*============================================================================*/ 577*============================================================================*/
578 578
579EAPI void 579EAPI void
580eina_stringshare_del(Eina_Stringshare str) 580eina_stringshare_del(Eina_Stringshare *str)
581{ 581{
582 int slen; 582 int slen;
583 583
@@ -611,13 +611,13 @@ eina_stringshare_del(Eina_Stringshare str)
611 CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str); 611 CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str);
612} 612}
613 613
614EAPI Eina_Stringshare 614EAPI Eina_Stringshare *
615eina_stringshare_add_length(const char *str, unsigned int slen) 615eina_stringshare_add_length(const char *str, unsigned int slen)
616{ 616{
617 if ((!str) || (slen <= 0)) 617 if ((!str) || (slen <= 0))
618 return ""; 618 return "";
619 else if (slen == 1) 619 else if (slen == 1)
620 return (Eina_Stringshare) _eina_stringshare_single + ((*str) << 1); 620 return (Eina_Stringshare *) _eina_stringshare_single + ((*str) << 1);
621 else if (slen < 4) 621 else if (slen < 4)
622 { 622 {
623 const char *s; 623 const char *s;
@@ -632,7 +632,7 @@ eina_stringshare_add_length(const char *str, unsigned int slen)
632 sizeof(char), sizeof(char)); 632 sizeof(char), sizeof(char));
633} 633}
634 634
635EAPI Eina_Stringshare 635EAPI Eina_Stringshare *
636eina_stringshare_add(const char *str) 636eina_stringshare_add(const char *str)
637{ 637{
638 int slen; 638 int slen;
@@ -653,7 +653,7 @@ eina_stringshare_add(const char *str)
653 return eina_stringshare_add_length(str, slen); 653 return eina_stringshare_add_length(str, slen);
654} 654}
655 655
656EAPI Eina_Stringshare 656EAPI Eina_Stringshare *
657eina_stringshare_printf(const char *fmt, ...) 657eina_stringshare_printf(const char *fmt, ...)
658{ 658{
659 va_list args; 659 va_list args;
@@ -677,7 +677,7 @@ eina_stringshare_printf(const char *fmt, ...)
677 return ret; 677 return ret;
678} 678}
679 679
680EAPI Eina_Stringshare 680EAPI Eina_Stringshare *
681eina_stringshare_vprintf(const char *fmt, va_list args) 681eina_stringshare_vprintf(const char *fmt, va_list args)
682{ 682{
683 char *tmp; 683 char *tmp;
@@ -698,7 +698,7 @@ eina_stringshare_vprintf(const char *fmt, va_list args)
698 return ret; 698 return ret;
699} 699}
700 700
701EAPI Eina_Stringshare 701EAPI Eina_Stringshare *
702eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) 702eina_stringshare_nprintf(unsigned int len, const char *fmt, ...)
703{ 703{
704 va_list args; 704 va_list args;
@@ -723,8 +723,8 @@ eina_stringshare_nprintf(unsigned int len, const char *fmt, ...)
723 return eina_stringshare_add_length(tmp, len); 723 return eina_stringshare_add_length(tmp, len);
724} 724}
725 725
726EAPI Eina_Stringshare 726EAPI Eina_Stringshare *
727eina_stringshare_ref(Eina_Stringshare str) 727eina_stringshare_ref(Eina_Stringshare *str)
728{ 728{
729 int slen; 729 int slen;
730 730
@@ -765,7 +765,7 @@ eina_stringshare_ref(Eina_Stringshare str)
765} 765}
766 766
767EAPI int 767EAPI int
768eina_stringshare_strlen(Eina_Stringshare str) 768eina_stringshare_strlen(Eina_Stringshare *str)
769{ 769{
770 int len; 770 int len;
771 /* special cases */ 771 /* special cases */
@@ -781,7 +781,7 @@ eina_stringshare_strlen(Eina_Stringshare str)
781 if (str[3] == '\0') 781 if (str[3] == '\0')
782 return 3; 782 return 3;
783 783
784 len = eina_share_common_length(stringshare_share, (Eina_Stringshare) str); 784 len = eina_share_common_length(stringshare_share, (Eina_Stringshare *) str);
785 len = (len > 0) ? len / (int)sizeof(char) : -1; 785 len = (len > 0) ? len / (int)sizeof(char) : -1;
786 return len; 786 return len;
787} 787}