Commit 2571929a77c2d1c77c9fd28341994eb69acda7b6

Authored by bellard
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
... ... @@ -294,6 +294,16 @@ void *qemu_mallocz(size_t size)
294 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 308 /* printf support */
299 309  
... ...
... ... @@ -10,6 +10,7 @@ void qemu_printf(const char *fmt, ...);
10 10 void *qemu_malloc(size_t size);
11 11 void *qemu_mallocz(size_t size);
12 12 void qemu_free(void *ptr);
  13 +char *qemu_strdup(const char *str);
13 14  
14 15 void *get_mmap_addr(unsigned long size);
15 16  
... ...