shithub: scc

ref: 186e05bb5830df614015417a929d44db151af1e9
dir: /ld/obj.c/

View raw version
static char sccsid[] = "@(#) ./ld/obj.c";

#include <stdlib.h>
#include <string.h>

#include "../inc/scc.h"
#include "ld.h"

Obj *objlst;
static Obj *tail;

Obj *
newobj(char *fname)
{
	Obj *obj;
	char *s;
	size_t len = strlen(fname);

	obj = malloc(sizeof(*obj));
	s = malloc(len+1);
	if (!obj || !s)
		die("ld: out of memory");

	obj->fname = memcpy(s, fname, len);
	obj->next = NULL;

	if (!objlst)
		tail = objlst = obj;
	else
		tail->next = obj;

	return obj;
}