Skip to content

Commit

Permalink
Added str_copy sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiannis128 committed Oct 2, 2023
1 parent 3b5bfcc commit dc7657e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions samples/optimize-code/str_copy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ESBMC: https://github.com/esbmc/esbmc/blob/master/src/c2goto/library/string.c

#include <stddef.h>

char *strncpy(char *dst, const char *src, size_t n)
{
__ESBMC_HIDE:;
char *start = dst;

while (n && (*dst++ = *src++))
n--;

if (n)
while (--n)
*dst++ = '\0';

return start;
}

int main()
{
return 0;
}

0 comments on commit dc7657e

Please sign in to comment.