Commit 2571929a77c2d1c77c9fd28341994eb69acda7b6
1 parent
81d0912d
added qemu_strdup()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1021 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
11 additions
and
0 deletions
osdep.c
@@ -294,6 +294,16 @@ void *qemu_mallocz(size_t size) | @@ -294,6 +294,16 @@ void *qemu_mallocz(size_t size) | ||
294 | return ptr; | 294 | return ptr; |
295 | } | 295 | } |
296 | 296 | ||
297 | +char *qemu_strdup(const char *str) | ||
298 | +{ | ||
299 | + char *ptr; | ||
300 | + ptr = qemu_malloc(strlen(str) + 1); | ||
301 | + if (!ptr) | ||
302 | + return NULL; | ||
303 | + strcpy(ptr, str); | ||
304 | + return ptr; | ||
305 | +} | ||
306 | + | ||
297 | /****************************************************************/ | 307 | /****************************************************************/ |
298 | /* printf support */ | 308 | /* printf support */ |
299 | 309 |
osdep.h
@@ -10,6 +10,7 @@ void qemu_printf(const char *fmt, ...); | @@ -10,6 +10,7 @@ void qemu_printf(const char *fmt, ...); | ||
10 | void *qemu_malloc(size_t size); | 10 | void *qemu_malloc(size_t size); |
11 | void *qemu_mallocz(size_t size); | 11 | void *qemu_mallocz(size_t size); |
12 | void qemu_free(void *ptr); | 12 | void qemu_free(void *ptr); |
13 | +char *qemu_strdup(const char *str); | ||
13 | 14 | ||
14 | void *get_mmap_addr(unsigned long size); | 15 | void *get_mmap_addr(unsigned long size); |
15 | 16 |