2008-05-02 21:05:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 Patrick Ohly
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libical/icalstrdup.h"
|
|
|
|
|
2008-10-09 17:55:11 +02:00
|
|
|
#if !defined(LIBICAL_MEMFIXES) || defined(EVOLUTION_COMPATIBILITY)
|
2008-05-02 21:05:37 +02:00
|
|
|
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_GNU_SOURCE) && defined(HAVE_DLFCN_H)
|
|
|
|
# include <dlfcn.h>
|
|
|
|
# define LIBICAL_RUNTIME_CHECK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
char *ical_strdup(const char *x)
|
|
|
|
{
|
|
|
|
#ifdef LIBICAL_RUNTIME_CHECK
|
|
|
|
static enum {
|
|
|
|
PATCH_UNCHECKED,
|
|
|
|
PATCH_FOUND,
|
|
|
|
PATCH_NOT_FOUND
|
|
|
|
} patch_status;
|
|
|
|
|
|
|
|
if (patch_status == PATCH_UNCHECKED) {
|
|
|
|
patch_status = dlsym(RTLD_NEXT, "ical_memfixes") != NULL ?
|
|
|
|
PATCH_FOUND : PATCH_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (patch_status == PATCH_FOUND) {
|
2008-05-04 17:40:34 +02:00
|
|
|
/* patch applied, no need to copy */
|
2008-05-02 21:05:37 +02:00
|
|
|
return (char *)x;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return x ? strdup(x) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !LIBICAL_MEMFIXES */
|