| Subject: | Re: memdup(3) |
|---|---|
| From: | Marc Balmer <marc@xxxxxxx> |
| Date: | Mon, 14 Jul 2008 15:16:38 UTC |
| Newsgroups: | fa.openbsd.tech |
* Alexey Dobriyan wrote: > memdup(3) has strdup(3) semantics but without strings. > > Canonical code for duplicating buffer looks like: > > rpl = malloc(src, len); > if (!rpl) > ... > memcpy(rpl, src, len); > > Mistakes happen and two lengths in snippet above will be different. > To prevent this memdup(3) was created: > > rpl = memdup(src, len); > if (!rpl) > ... > ... I dislike this a lot. It is not available anywhere else, for a start. |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: memdup(3), Marco Peereboom |
|---|---|
| Next by Date: | Re: memdup(3), Alexey Dobriyan |
| Previous by Thread: | Re: memdup(3), Tobias Weingartner |
| Next by Thread: | Re: memdup(3), Damien Miller |
| Indexes: | [Date] [Thread] [Top] [All Lists] |