# endif
#endif /* STDC_HEADERS */
#ifdef HAVE_STRING_H
+# if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS)
+# include <memory.h>
+# endif
# include <string.h>
#endif /* HAVE_STRING_H */
#ifdef HAVE_STRINGS_H
# include <inttypes.h>
#endif
-#include "sudo.h"
+#include "missing.h"
+#include "alloc.h"
+#include "error.h"
/*
* If there is no SIZE_MAX or SIZE_T_MAX we have to assume that size_t
if ((ptr = malloc(size)) == NULL)
errorx(1, "unable to allocate memory");
- return(ptr);
+ return ptr;
}
/*
size *= nmemb;
if ((ptr = malloc(size)) == NULL)
errorx(1, "unable to allocate memory");
- return(ptr);
+ return ptr;
}
/*
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
errorx(1, "unable to allocate memory");
- return(ptr);
+ return ptr;
}
/*
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
errorx(1, "unable to allocate memory");
- return(ptr);
+ return ptr;
}
/*
const char *src;
{
char *dst = NULL;
- size_t size;
+ size_t len;
if (src != NULL) {
- size = strlen(src) + 1;
- dst = (char *) emalloc(size);
- (void) memcpy(dst, src, size);
+ len = strlen(src);
+ dst = (char *) emalloc(len + 1);
+ (void) memcpy(dst, src, len);
+ dst[len] = '\0';
}
- return(dst);
+ return dst;
}
/*
if (len == -1)
errorx(1, "unable to allocate memory");
- return(len);
+ return len;
}
/*
if ((len = vasprintf(ret, format, args)) == -1)
errorx(1, "unable to allocate memory");
- return(len);
+ return len;
}
/*