chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
infra: Clean up project setup
[mLib]
/
env.c
diff --git
a/env.c
b/env.c
index 4a4fbe5494ae4d1d7a37a4b2eabfe7b5b263bfb4..57d029a522971e7cc5ee48a8caadf2d893eda222 100644
(file)
--- a/
env.c
+++ b/
env.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: env.c,v 1.
1 1999/07/26 23:15:57
mdw Exp $
+ * $Id: env.c,v 1.
5 2004/04/08 01:36:11
mdw Exp $
*
* Fiddling with environment variables
*
*
* Fiddling with environment variables
*
@@
-27,14
+27,6
@@
* MA 02111-1307, USA.
*/
* MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: env.c,v $
- * Revision 1.1 1999/07/26 23:15:57 mdw
- * Fiddling with environment variables.
- *
- */
-
/*----- Header files ------------------------------------------------------*/
#include <stdio.h>
/*----- Header files ------------------------------------------------------*/
#include <stdio.h>
@@
-97,7
+89,7
@@
void env_put(sym_table *t, const char *name, const char *value)
{
size_t eq = strcspn(name, "=");
if (name[eq] == '=') {
{
size_t eq = strcspn(name, "=");
if (name[eq] == '=') {
- q = x
malloc(
eq + 1);
+ q = x
_alloc(t->t.a,
eq + 1);
memcpy(q, name, eq);
q[eq] = 0;
value = name + eq + 1;
memcpy(q, name, eq);
q[eq] = 0;
value = name + eq + 1;
@@
-110,21
+102,21
@@
void env_put(sym_table *t, const char *name, const char *value)
if (!value) {
var *v;
if ((v = sym_find(t, name, -1, 0, 0)) != 0) {
if (!value) {
var *v;
if ((v = sym_find(t, name, -1, 0, 0)) != 0) {
-
free(
v->v);
+
x_free(t->t.a,
v->v);
sym_remove(t, v);
}
} else {
unsigned found;
var *v = sym_find(t, name, -1, sizeof(*v), &found);
if (found)
sym_remove(t, v);
}
} else {
unsigned found;
var *v = sym_find(t, name, -1, sizeof(*v), &found);
if (found)
-
free(
v->v);
- v->v = x
strdup(
value);
+
x_free(t->t.a,
v->v);
+ v->v = x
_strdup(t->t.a,
value);
}
/* --- Tidying --- */
if (q)
}
/* --- Tidying --- */
if (q)
- free(q);
+
x
free(q);
}
/* --- @env_import@ --- *
}
/* --- @env_import@ --- *
@@
-171,7
+163,7
@@
char **env_export(sym_table *t)
for (sym_mkiter(&i, t); (v = sym_next(&i)) != 0; ) {
n++;
for (sym_mkiter(&i, t); (v = sym_next(&i)) != 0; ) {
n++;
- sz +=
strlen(SYM_NAME(v)
) + strlen(v->v) + 2;
+ sz +=
SYM_LEN(v
) + strlen(v->v) + 2;
}
/* --- Allocate the big chunk of memory --- */
}
/* --- Allocate the big chunk of memory --- */
@@
-209,7
+201,7
@@
void env_destroy(sym_table *t)
var *v;
for (sym_mkiter(&i, t); (v = sym_next(&i)) != 0; )
var *v;
for (sym_mkiter(&i, t); (v = sym_next(&i)) != 0; )
-
free(
v->v);
+
x_free(t->t.a,
v->v);
sym_destroy(t);
}
sym_destroy(t);
}