aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@finestructure.net>2009-12-05 01:19:53 -0500
committerJameson Graef Rollins <jrollins@finestructure.net>2009-12-05 01:20:11 -0500
commite72a6176e3fc3fcf4b1696e3f0ee9cf66509fb4d (patch)
tree7015964358d20934cbc78a50340870d9b81fcd1f /lib
parent4edf37a1d5067197741b8dcb0bdb72ce4c299c05 (diff)
parent263aeb82f0a1a69864ca41cff4dfa2ae0b8b3f05 (diff)
merge changes from upstream
Diffstat (limited to 'lib')
-rw-r--r--lib/index.cc10
-rw-r--r--lib/notmuch-private.h14
-rw-r--r--lib/xutil.c8
3 files changed, 13 insertions, 19 deletions
diff --git a/lib/index.cc b/lib/index.cc
index 80df64bf..125fa6c9 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -31,7 +31,7 @@ _index_address_mailbox (notmuch_message_t *message,
{
InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
const char *name, *addr;
- int own_name = 0;
+ void *local = talloc_new (NULL);
name = internet_address_get_name (address);
addr = internet_address_mailbox_get_addr (mailbox);
@@ -42,16 +42,16 @@ _index_address_mailbox (notmuch_message_t *message,
const char *at;
at = strchr (addr, '@');
- if (at) {
- name = strndup (addr, at - addr);
- own_name = 1;
- }
+ if (at)
+ name = talloc_strndup (local, addr, at - addr);
}
if (name)
_notmuch_message_gen_terms (message, prefix_name, name);
if (addr)
_notmuch_message_gen_terms (message, prefix_name, addr);
+
+ talloc_free (local);
}
static void
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index d3f9a4c4..0c340a76 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -26,6 +26,8 @@
#endif
#include <stdio.h>
+#include "compat.h"
+
#include "notmuch.h"
NOTMUCH_BEGIN_DECLS
@@ -330,18 +332,6 @@ void
_notmuch_message_add_reply (notmuch_message_t *message,
notmuch_message_node_t *reply);
-/* date.c */
-
-/* Parse an RFC 8222 date string to a time_t value.
- *
- * The tz_offset argument can be used to also obtain the time-zone
- * offset, (but can be NULL if the call is not interested in that).
- *
- * Returns 0 on error.
- */
-time_t
-notmuch_parse_date (const char *str, int *tz_offset);
-
/* sha1.c */
char *
diff --git a/lib/xutil.c b/lib/xutil.c
index 6fa5eb0d..268225b8 100644
--- a/lib/xutil.c
+++ b/lib/xutil.c
@@ -18,7 +18,6 @@
* Author: Carl Worth <cworth@cworth.org>
*/
-#define _GNU_SOURCE /* For strndup */
#include "notmuch-private.h"
#include <stdio.h>
@@ -84,11 +83,16 @@ xstrndup (const char *s, size_t n)
{
char *ret;
- ret = strndup (s, n);
+ if (strlen (s) <= n)
+ n = strlen (s);
+
+ ret = malloc (n + 1);
if (ret == NULL) {
fprintf (stderr, "Out of memory.\n");
exit (1);
}
+ memcpy (ret, s, n);
+ ret[n] = '\0';
return ret;
}