A small library that's provide helpers for programmers
MyLibc.cpp@1:ee7a5f05513d, 2015-02-17 (annotated)
- Committer:
- clemounet
- Date:
- Tue Feb 17 11:55:34 2015 +0000
- Revision:
- 1:ee7a5f05513d
more Things
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
clemounet | 1:ee7a5f05513d | 1 | |
clemounet | 1:ee7a5f05513d | 2 | #include "MyLibc.h" |
clemounet | 1:ee7a5f05513d | 3 | |
clemounet | 1:ee7a5f05513d | 4 | #include "mbed.h" |
clemounet | 1:ee7a5f05513d | 5 | |
clemounet | 1:ee7a5f05513d | 6 | char *strdup(const char *str) { |
clemounet | 1:ee7a5f05513d | 7 | uint32_t len; |
clemounet | 1:ee7a5f05513d | 8 | char *copy; |
clemounet | 1:ee7a5f05513d | 9 | |
clemounet | 1:ee7a5f05513d | 10 | len = strlen(str) + 1; |
clemounet | 1:ee7a5f05513d | 11 | if (!(copy = (char*)malloc(len))) |
clemounet | 1:ee7a5f05513d | 12 | return 0; |
clemounet | 1:ee7a5f05513d | 13 | strncpy(copy,str,len); |
clemounet | 1:ee7a5f05513d | 14 | return copy; |
clemounet | 1:ee7a5f05513d | 15 | } |