Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
757 B

#ifdef __dietlibc__
#include <sys/cdefs.h>
#define __likely(x) x
#define __unlikely(x) x
#include "safemult.h"
#include "array.h"
#if 0
static array x;
t *p;
int64 pos;
p = array_get(&x,sizeof(t),pos);
array_get is similar to array_allocate, but it does not allocate any
extra bytes, and it does not initialize any extra bytes. It
returns 0 if x is unallocated, for example, or if fewer than
(pos+1)*sizeof(t) bytes are initialized.
void* array_get(array* x,uint64 membersize,int64 pos) {
uint64 wanted;
if (__unlikely(pos+1<1)) return 0;
if (__unlikely(!umult64(membersize,pos,&wanted))) return 0;
if (__unlikely((int64)wanted >= x->allocated)) return 0;
return x->p+pos*membersize;