Both programs will want it soon enough.
void error(const char *m);
void *xmalloc(size_t sz);
void xsetenv(const char *en, const char *ev, int overwrite);
void error(const char *m);
void *xmalloc(size_t sz);
void xsetenv(const char *en, const char *ev, int overwrite);
+void *xrealloc(void *ptr, size_t sz);
extern const char *const envok[];
extern const int nenvok;
extern const char *const envok[];
extern const int nenvok;
+void *xrealloc(void *ptr, size_t sz) {
+ void *r;
+
+ r= realloc(ptr,sz);
+ if (!r) syserror("realloc failed");
+ return r;
+}
+
void xsetenv(const char *en, const char *ev, int overwrite) {
if (setenv(en,ev,overwrite)) syserror("setenv");
}
void xsetenv(const char *en, const char *ev, int overwrite) {
if (setenv(en,ev,overwrite)) syserror("setenv");
}
-static void *xrealloc(void *ptr, size_t sz) {
- void *r;
-
- r= realloc(ptr,sz);
- if (!r) syserror("realloc failed");
- return r;
-}
-
int main(int argc, const char **argv) {
char *uservarn, *scriptpath, *newvar;
const char *nextslash, *lastslash, *pathi, *ev, *ev2, *en, *scriptdir, *av;
int main(int argc, const char **argv) {
char *uservarn, *scriptpath, *newvar;
const char *nextslash, *lastslash, *pathi, *ev, *ev2, *en, *scriptdir, *av;