diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-20 14:50:12 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-20 14:50:12 -0400 |
commit | fadd46012c9974931add6c36e69636d3cbc6906f (patch) | |
tree | d1af6084772830074be18cf7a9dd93c2ec3d3f59 /src/user/knob/block.c | |
parent | de20d7430df08731d9108acb83e1234ba7f1fe16 (diff) | |
download | portland-os-fadd46012c9974931add6c36e69636d3cbc6906f.tar.gz |
history when getting line from user in knob
Diffstat (limited to 'src/user/knob/block.c')
-rw-r--r-- | src/user/knob/block.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/user/knob/block.c b/src/user/knob/block.c index 4ec0564..94bd073 100644 --- a/src/user/knob/block.c +++ b/src/user/knob/block.c @@ -1,5 +1,6 @@ -#include <stdint.h> #include <stdbool.h> +#include <stdint.h> +#include <knob/heap.h> //unsophisticated, should copy by dwords where available void blockcpy(void *to, const void *from, uint32_t size) { @@ -23,4 +24,13 @@ uint32_t strcpy(char *to, const char *from) { to[i] = from[i]; while (from[i++]); return i - 1; +} + +char *strdup(const char *from) { + const char *end = from; + while (*(end++)) + ; + char *buf = get_block(end - from); + blockcpy(buf, from, end - from); + return buf; }
\ No newline at end of file |