summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-02 09:30:49 +0100
committerTom Hacohen <tom@stosb.com>2015-10-02 09:30:49 +0100
commitb33923ceed1b305aa9319303c41b374ee153ed46 (patch)
tree7a17f1adf5a903cfb94ab3e585ea53368ce6456e
parentb38f8a3f39008845ac42ee04a83cf76c23b281c0 (diff)
Revert "eina_tmpstr: add eina_tmpstr_strftime"
As agreed on the ML, eina_tmpstr_strftime() should be removed. This reverts commit abaf29cb768375957c9ee0b64d36034c21c618ea.
Diffstat (limited to '')
-rw-r--r--AUTHORS1
-rw-r--r--src/lib/eina/eina_tmpstr.c39
-rw-r--r--src/lib/eina/eina_tmpstr.h25
3 files changed, 2 insertions, 63 deletions
diff --git a/AUTHORS b/AUTHORS
index f714c39aad..eab2011b7a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -53,7 +53,6 @@ ChunEon Park (Hermet) <hermet@hermet.pe.kr>
53Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com> 53Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com>
54Subodh Kumar <s7158.kumar@samsung.com> 54Subodh Kumar <s7158.kumar@samsung.com>
55Michelle Legrand <legrand.michelle@outlook.com> 55Michelle Legrand <legrand.michelle@outlook.com>
56Shilpa Singh <shilpa.singh@samsung.com> <shilpasingh.o@gmail.com>
57 56
58Eet 57Eet
59--- 58---
diff --git a/src/lib/eina/eina_tmpstr.c b/src/lib/eina/eina_tmpstr.c
index 5b81819013..43824b759b 100644
--- a/src/lib/eina/eina_tmpstr.c
+++ b/src/lib/eina/eina_tmpstr.c
@@ -133,48 +133,13 @@ eina_tmpstr_len(Eina_Tmpstr *tmpstr)
133 for (s = strs; s; s = s->next) 133 for (s = strs; s; s = s->next)
134 { 134 {
135 if (s->str == tmpstr) 135 if (s->str == tmpstr)
136 { 136 {
137 size_t ret = s->length; 137 size_t ret = s->length;
138 eina_lock_release(&_mutex); 138 eina_lock_release(&_mutex);
139 return ret; 139 return ret;
140 } 140 }
141 } 141 }
142 eina_lock_release(&_mutex); 142 eina_lock_release(&_mutex);
143 143
144 return strlen(tmpstr); 144 return strlen(tmpstr);
145} 145}
146
147EAPI Eina_Tmpstr *
148eina_tmpstr_strftime(const char *format, const struct tm *tm)
149{
150 const size_t flen = strlen(format);
151 size_t buflen = 16; // An arbitrary starting size
152 char *buf = NULL;
153
154 do {
155 char *tmp;
156 size_t len;
157
158 tmp = realloc(buf, buflen * sizeof(char));
159 if (!tmp) goto on_error;
160 buf = tmp;
161
162 len = strftime(buf, buflen, format, tm);
163 // Check if we have the expected result and return it.
164 if ((len > 0 && len < buflen) || (len == 0 && flen == 0))
165 {
166 Eina_Tmpstr *r;
167
168 r = eina_tmpstr_add_length(buf, len + 1);
169 free(buf);
170 return r;
171 }
172
173 /* Possibly buf overflowed - try again with a bigger buffer */
174 buflen <<= 1; // multiply buffer size by 2
175 } while (buflen < 128 * flen);
176
177 on_error:
178 free(buf);
179 return NULL;
180}
diff --git a/src/lib/eina/eina_tmpstr.h b/src/lib/eina/eina_tmpstr.h
index 8d9f5174c0..f784a67acc 100644
--- a/src/lib/eina/eina_tmpstr.h
+++ b/src/lib/eina/eina_tmpstr.h
@@ -238,31 +238,6 @@ EAPI size_t eina_tmpstr_len(Eina_Tmpstr *tmpstr);
238EAPI void eina_tmpstr_del(Eina_Tmpstr *tmpstr) EINA_ARG_NONNULL(1); 238EAPI void eina_tmpstr_del(Eina_Tmpstr *tmpstr) EINA_ARG_NONNULL(1);
239 239
240/** 240/**
241 * @brief Add a new temporary string based on strftime output.
242 *
243 * @param tm Pointer to a tm structure needed by strftime.
244 * @param format String containing format specifiers needed by strftime.
245 *
246 * This will add a new temporary string by updating the string value by output
247 * of strftime.
248 *
249 * Example usage:
250 *
251 * @code
252 * time_t curr_time;
253 * struct tm * info;
254 * Eina_Tmpstr *buf;
255 *
256 * curr_time = time(NULL);
257 * info = localtime(&curr_time);
258 * buf = eina_tmpstr_strftime("%I:%M%p", info);
259 * @endcode
260 *
261 * @since 1.16.0
262 */
263EAPI Eina_Tmpstr *eina_tmpstr_strftime(const char *format, const struct tm *tm) EINA_ARG_NONNULL(2);
264
265/**
266 * @} 241 * @}
267 */ 242 */
268 243