projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
only use memcpy realloc to shrink if an exact-sized free chunk exists
[oweals/musl.git]
/
src
/
stdio
/
gets.c
1
#include "stdio_impl.h"
2
#include <limits.h>
3
#include <string.h>
4
5
char *gets(char *s)
6
{
7
size_t i=0;
8
int c;
9
FLOCK(stdin);
10
while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c;
11
s[i] = 0;
12
if (c != '\n' && (!feof(stdin) || !i)) s = 0;
13
FUNLOCK(stdin);
14
return s;
15
}