diff options
Diffstat (limited to 'lexer/misc.c')
-rw-r--r-- | lexer/misc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lexer/misc.c b/lexer/misc.c new file mode 100644 index 0000000..9014421 --- /dev/null +++ b/lexer/misc.c @@ -0,0 +1,14 @@ +/* Name: cnvstr() + * Desc: Converts a pointer, and length pair into a null-terminated string. + * Args: + * s: Pointer to convert. + * len: Length to convert. + * Return value: Returns a null-terminated string. + */ + +char *cnvstr(char *s, int len) { + char *p = malloc(len+1); + memcpy(p, s, len); + p[len] = '\0'; + return p; +} |