Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b232e073 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Add memdup function



Adding memdup function to duplicate region of memory.

  void *memdup(const void *src, size_t len)

Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1347295819-23177-3-git-send-email-jolsa@redhat.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent bdde3716
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
#include <string.h>

void *memdup(const void *src, size_t len);
+17 −1
Original line number Diff line number Diff line
#include "util.h"
#include "string.h"
#include "linux/string.h"

#define K 1024LL
/*
@@ -335,3 +335,19 @@ char *rtrim(char *s)

	return s;
}

/**
 * memdup - duplicate region of memory
 * @src: memory region to duplicate
 * @len: memory region length
 */
void *memdup(const void *src, size_t len)
{
	void *p;

	p = malloc(len);
	if (p)
		memcpy(p, src, len);

	return p;
}