help-gplusplus
[Top][All Lists]
Advanced

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

Re: Realizing memdup() compactly in C++


From: Nordlöw
Subject: Re: Realizing memdup() compactly in C++
Date: Thu, 14 May 2009 07:28:13 -0700 (PDT)
User-agent: G2/1.0

On 14 Maj, 15:24, Nordlöw <per.nord...@gmail.com> wrote:
> Han anybody written any snippet (template i guess) that realizes memdup
> () using the operator new. Suggested name: new_duplicate.
>
> Thanks in advance,
> Nordlöw

Ooops, memdup() was defined by me... Here's the definition:

static inline char *
memdup(const char *s, size_t n)
{
  char * t = (char*)malloc(n);
  memcpy(t, s, n);
  return t;

}

Sorry,
Nordlöw


reply via email to

[Prev in Thread] Current Thread [Next in Thread]