mailing list of musl libc
 help / color / mirror / code / Atom feed
76e8ee1206e5b5a4111b8c58481932952de6084f blob 514 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
#include <stdlib.h>
#include <string.h>
#include <errno.h>

int __putenv(char *s, int a);

int setenv(const char *var, const char *value, int overwrite)
{
	char *s;
	int l1, l2;

	if (!var || !*var || strchr(var, '=')) {
		errno = EINVAL;
		return -1;
	}
	if (!overwrite && getenv(var)) return 0;

	l1 = strlen(var);
	l2 = strlen(value);
	s = malloc(l1+l2+2);
	if (s) {
		memcpy(s, var, l1);
		s[l1] = '=';
		memcpy(s+l1+1, value, l2);
		s[l1+l2+1] = 0;
		if (!__putenv(s, 1)) return 0;
	}
	free(s);
	return -1;
}
debug log:

solving 76e8ee1 ...
found 76e8ee1 in https://git.vuxu.org/mirror/musl/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).