Re: [PATCH kvm-unit-tests 1/4] libcflat: add a few more runtime functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/12/2020 02.08, Paolo Bonzini wrote:
These functions will be used to parse the chaos test's command line.

Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
  lib/alloc.c    |  9 +++++++-
  lib/alloc.h    |  1 +
  lib/libcflat.h |  4 +++-
  lib/string.c   | 59 +++++++++++++++++++++++++++++++++++++++++++++++---
  lib/string.h   |  3 +++
  5 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/lib/alloc.c b/lib/alloc.c
index a46f464..a56f664 100644
--- a/lib/alloc.c
+++ b/lib/alloc.c
@@ -1,7 +1,7 @@
  #include "alloc.h"
  #include "bitops.h"
  #include "asm/page.h"
-#include "bitops.h"
+#include "string.h"
void *malloc(size_t size)
  {
@@ -50,6 +50,13 @@ void *calloc(size_t nmemb, size_t size)
  	return ptr;
  }
+char *strdup(const char *s)
+{
+	size_t len = strlen(s) + 1;
+	char *d = malloc(len);
+	return strcpy(d, s);
+}
+
  void free(void *ptr)
  {
  	if (alloc_ops->free)
diff --git a/lib/alloc.h b/lib/alloc.h
index 9b4b634..4139465 100644
--- a/lib/alloc.h
+++ b/lib/alloc.h
@@ -34,5 +34,6 @@ void *malloc(size_t size);
  void *calloc(size_t nmemb, size_t size);
  void free(void *ptr);
  void *memalign(size_t alignment, size_t size);
+char *strdup(const char *s);

Why did you put the prototype in alloc.h and not in string.h?

 Thomas




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux