]> Git Repo - qemu.git/blobdiff - cutils.c
Tosa: emulate LEDs (Dmitry Baryshkov).
[qemu.git] / cutils.c
index 738d5265d7be722c8926114c1582a12d314808c1..8fcb62efed184a4ad48792d839ae2fee2933a1d0 100644 (file)
--- a/cutils.c
+++ b/cutils.c
@@ -50,6 +50,18 @@ char *pstrcat(char *buf, int buf_size, const char *s)
     return buf;
 }
 
+/* strdup with a limit */
+char *pstrdup(const char *str, size_t buf_size)
+{
+    size_t len;
+    char *buf;
+
+    len = MIN(buf_size, strlen(str));
+    buf = qemu_malloc(len);
+    pstrcpy(buf, len, str);
+    return buf;
+}
+
 int strstart(const char *str, const char *val, const char **ptr)
 {
     const char *p, *q;
@@ -95,38 +107,3 @@ time_t mktimegm(struct tm *tm)
     t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
     return t;
 }
-
-void *get_mmap_addr(unsigned long size)
-{
-    return NULL;
-}
-
-void qemu_free(void *ptr)
-{
-    free(ptr);
-}
-
-void *qemu_malloc(size_t size)
-{
-    return malloc(size);
-}
-
-void *qemu_mallocz(size_t size)
-{
-    void *ptr;
-    ptr = qemu_malloc(size);
-    if (!ptr)
-        return NULL;
-    memset(ptr, 0, size);
-    return ptr;
-}
-
-char *qemu_strdup(const char *str)
-{
-    char *ptr;
-    ptr = qemu_malloc(strlen(str) + 1);
-    if (!ptr)
-        return NULL;
-    strcpy(ptr, str);
-    return ptr;
-}
This page took 0.023663 seconds and 4 git commands to generate.