shithub: lpa

ref: 7d2f1a2d83df21f0520180537eba7f930bbdb7ee
dir: /util.c/

View raw version
#include <u.h>
#include <libc.h>
#include <thread.h>

#include "dat.h"
#include "fns.h"

Enumeration *
allocenum(uvlong count)
{
	Enumeration *e = alloc(DataEnumeration);
	setroot(e, 1);
	e->count = count;
	e->items = allocextra(e, sizeof(void *) * count);
	return e;
}

void
trim(char *str)
{
	for(int i = strlen(str)-1; i > 0; i--){
		if(str[i] != '\n')
			break;
		else
			str[i] = 0;
	}
}