00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "libical/icalstrdup.h"
00021
00022 #if !defined(LIBICAL_MEMFIXES) || defined(EVOLUTION_COMPATIBILITY)
00023
00024 #if defined(HAVE_CONFIG_H)
00025 # include <config.h>
00026 #endif
00027
00028 #if defined(_GNU_SOURCE) && defined(HAVE_DLFCN_H)
00029 # include <dlfcn.h>
00030 # define LIBICAL_RUNTIME_CHECK
00031 #endif
00032
00033 #include <string.h>
00034
00035 char *ical_strdup(const char *x)
00036 {
00037 #ifdef LIBICAL_RUNTIME_CHECK
00038 static enum {
00039 PATCH_UNCHECKED,
00040 PATCH_FOUND,
00041 PATCH_NOT_FOUND
00042 } patch_status;
00043
00044 if (patch_status == PATCH_UNCHECKED) {
00045 patch_status = dlsym(RTLD_NEXT, "ical_memfixes") != NULL ?
00046 PATCH_FOUND : PATCH_NOT_FOUND;
00047 }
00048
00049 if (patch_status == PATCH_FOUND) {
00050
00051 return (char *)x;
00052 }
00053 #endif
00054
00055 return x ? strdup(x) : NULL;
00056 }
00057
00058 #endif