4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since b33a242 was
8d1956e,
checked in by Daniel Lawson <dlawson@…>, 17 years ago
|
typo in conditional in strndup.c
typos in trace.c
|
-
Property mode set to
100644
|
File size:
535 bytes
|
Rev | Line | |
---|
[808a478] | 1 | /* |
---|
| 2 | * Written by mjl. Needs attributation? |
---|
| 3 | */ |
---|
| 4 | #include "../config.h" |
---|
| 5 | |
---|
[8d1956e] | 6 | #ifndef HAVE_STRNDUP |
---|
[808a478] | 7 | |
---|
| 8 | #include <stdlib.h> |
---|
| 9 | #include <errno.h> |
---|
| 10 | #include <string.h> |
---|
| 11 | |
---|
| 12 | char *strndup(const char *s, size_t size) |
---|
| 13 | { |
---|
| 14 | char *str; |
---|
| 15 | size_t len; |
---|
| 16 | |
---|
| 17 | if(size == 0 || s == NULL) |
---|
| 18 | { |
---|
| 19 | errno = EINVAL; |
---|
| 20 | return NULL; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | if(size > (len = strlen(s))) |
---|
| 24 | { |
---|
| 25 | size = len+1; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | if((str = malloc(size)) == NULL) |
---|
| 29 | { |
---|
| 30 | errno = ENOMEM; |
---|
| 31 | return NULL; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | memcpy(str, s, size); |
---|
| 35 | str[size-1] = '\0'; |
---|
| 36 | |
---|
| 37 | return str; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.