Commit 5630d289 authored by hkrishna's avatar hkrishna

warning fixes for third_party_builtin directory

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23633 18c085ea-50e0-402c-830e-de6fd14e8384
parent 00182456
......@@ -144,8 +144,8 @@ bool overlap(const interval<T, Policies1>& x,
const interval<T, Policies2>& y)
{
if (interval_lib::detail::test_input(x, y)) return false;
return x.lower() <= y.lower() && y.lower() <= x.upper() ||
y.lower() <= x.lower() && x.lower() <= y.upper();
return (x.lower() <= y.lower() && y.lower() <= x.upper()) ||
(y.lower() <= x.lower() && x.lower() <= y.upper());
}
template<class T, class Policies> inline
......
......@@ -125,7 +125,8 @@ extern char **libenvp;
COUT((K>>8)&0xff) COUT(K&0xff) \
}
#define FOUT(X) { int fout_i; f=(X); fout_i= *((int *)(&f)); IOUT(fout_i) }
//#define FOUT(X) { int fout_i; f=(X); fout_i= *((int *)(&f)); IOUT(fout_i) }
#define FOUT(X) { union { float f; int i; } fout; fout.f=(X); IOUT(fout.i) }
#define HEADOUT { \
IOUT(n) IOUT(ti) IOUT(bi) SOUT(vi) FOUT(v0) FOUT(v1) \
......@@ -140,7 +141,8 @@ extern char **libenvp;
#define IIN(X) { K= *ub++; K=(K<<8)|(*ub++); K=(K<<8)|(*ub++); \
K=(K<<8)|(*ub++); (X)=K; }
#define FIN(X) { int fin_i; IIN(fin_i) (X)= *((float *)(&fin_i)); }
//#define FIN(X) { int fin_i; IIN(fin_i) (X)= *((float *)(&fin_i)); }
#define FIN(X) { union { float f; int i; } fin; IIN(fin.i) (X)= fin.f; }
#define HEADIN { \
IIN(n) IIN(ti) IIN(bi) SIN(vi) FIN(v0) FIN(v1) \
......@@ -151,7 +153,7 @@ extern char **libenvp;
static void find_tmpdir(char *tmpdir);
static char *fioX_read(bowglobal bg,char *pathsrc);
static int fioX_write(char *pathdst,char *buf,int size);
static int fioX_size(const char *pathsrc);
//static int fioX_size(const char *pathsrc);
static int fioX_isdir(const char *pathsrc);
static int my_floor(float f);
static void bowglobal_adderror(bowglobal bg);
......@@ -343,7 +345,7 @@ int bof2bow(bowglobal bg,int ti,int bi,int vi,int xs,int ys,int zs,
float *bow2bof(bowglobal bg,char *bow,int bowi)
{
int size,offset,notran,ti,bi,vi,xs,ys,zs,x0,y0,z0;
int size,offset,notran/*,ti,bi,vi*/,xs,ys,zs/*,x0,y0,z0*/;
int i,j,k,n,bigcnt,ibig[256],kio;
int ntab[40],nti,ntimax,s;
short *vshrt;
......@@ -365,8 +367,8 @@ float *bow2bof(bowglobal bg,char *bow,int bowi)
#define XCOP(X) { X=binf->X[bowi]; }
XCOP(size) XCOP(offset) XCOP(notran) XCOP(ti) XCOP(bi) XCOP(vi)
XCOP(xs) XCOP(ys) XCOP(zs) XCOP(x0) XCOP(y0) XCOP(z0) XCOP(v0) XCOP(v1)
XCOP(size) XCOP(offset) XCOP(notran) /*XCOP(ti) XCOP(bi) XCOP(vi)*/
XCOP(xs) XCOP(ys) XCOP(zs) /*XCOP(x0) XCOP(y0) XCOP(z0)*/ XCOP(v0) XCOP(v1)
ub=(unsigned char *)(bow+(offset+4+HEADSIZE));
bigcnt= *ub++;
......@@ -384,7 +386,7 @@ float *bow2bof(bowglobal bg,char *bow,int bowi)
sprintf(tmpnamegz,"%s.gz",tmpname);
fioX_write(tmpnamegz,(char *)ub,size-FULLHEADSIZE);
sprintf(cmd,"gunzip %s",tmpnamegz);
system(cmd);
int res = system(cmd); (void)res;
unlink(tmpnamegz);
vshrt=(short *)fioX_read(bg,tmpname);
unlink(tmpname);
......@@ -486,7 +488,7 @@ float *bow2bof(bowglobal bg,char *bow,int bowi)
bowinfo bow_getbowinfo(bowglobal bg,char *bow)
{
int i,n,ti,bi,vi,xs,ys,zs,x0,y0,z0,iscat,nb,size,offset,notran;
int i,n,ti,bi,vi,xs,ys,zs,x0,y0,z0/*,iscat*/,nb,size,offset,notran;
int kio,ksio;
float v0,v1;
bowinfo binf;
......@@ -507,8 +509,8 @@ bowinfo bow_getbowinfo(bowglobal bg,char *bow)
ub=(unsigned char *)(bow+4);
HEADIN
if (n<0)
{ iscat=1; nb= -n; ub=(unsigned char *)(bow+8); offset=8+nb*HEADSIZE; }
else { iscat=0; nb=1; ub=(unsigned char *)(bow+4); offset=0; }
{ /*iscat=1;*/ nb= -n; ub=(unsigned char *)(bow+8); offset=8+nb*HEADSIZE; }
else { /*iscat=0;*/ nb=1; ub=(unsigned char *)(bow+4); offset=0; }
/*...more: test all these alloc calls for failure, deal with it */
......@@ -550,7 +552,7 @@ char *bow_cat(bowglobal bg,int numbow,char **bowtab)
{
int bowi,nbow,size,k,ks,js,ii,kio,ksio;
int b,n,nb,ti,bi,vi,xs,ys,zs,x0,y0,z0;
float v0,v1,f;
float v0,v1/*,f*/;
char *bow,*buf;
unsigned char *ub;
......@@ -760,21 +762,21 @@ typedef off_t VisItOff_t;
//
// ****************************************************************************
static int
VisItStat(const char *file_name, VisItStat_t *buf)
{
#if defined(_WIN32)
return _stat(file_name, buf);
#else
//static int
//VisItStat(const char *file_name, VisItStat_t *buf)
//{
//#if defined(_WIN32)
// return _stat(file_name, buf);
//#else
#if SIZEOF_OFF64_T > 4
return stat64(file_name, buf);
#else
return stat(file_name, buf);
#endif
//#if SIZEOF_OFF64_T > 4
// return stat64(file_name, buf);
//#else
// return stat(file_name, buf);
//#endif
#endif
}
//#endif
//}
// ****************************************************************************
// Method: VisItFStat
......@@ -849,14 +851,14 @@ static int fioX_write(char *pathdst,char *buf,int size)
/* return size of file or -1 on error */
static int fioX_size(const char *pathsrc)
{
static VisItStat_t st_store;
static VisItStat_t *st = &st_store;
//static int fioX_size(const char *pathsrc)
//{
// static VisItStat_t st_store;
// static VisItStat_t *st = &st_store;
if (VisItStat(pathsrc,st)) return -1;
return st->st_size;
}
// if (VisItStat(pathsrc,st)) return -1;
// return st->st_size;
//}
/* return 1 if dir and exists, 0 otherwise */
......@@ -874,7 +876,13 @@ static int fioX_isdir(const char *pathsrc)
static int my_floor(float f)
{
f=(f-0.25f)+(float)0x00600000;
return ((*((int *)(&f)))>>1)-0x25600000;
union {
float a;
int b;
} x;
x.a = f;
return (x.b>>1)-0x25600000;
//return ((*((int *)(&f)))>>1)-0x25600000;
}
......
......@@ -256,11 +256,11 @@ void fwav_atran_x(fwav fw,float *ba0,int dx,int dy,int dz)
void fwav_atran_y(fwav fw,float *b0,int dx,int dy,int dz)
{
int j,dy2,y,z;
int j/*,dy2*/,y,z;
float *ba0,*ba1,*ba2,*bb,v1,td0,td1;
td0=fw->td0; td1=fw->td1;
dy2=HALF(dy); bb=fw->bt;
/*dy2=HALF(dy);*/ bb=fw->bt;
for (z=0;z<dz;z++) {
for (y=0;y+1<dy;y+=2) {
ba0=b0+(z*dy+y)*dx;
......@@ -285,11 +285,11 @@ void fwav_atran_y(fwav fw,float *b0,int dx,int dy,int dz)
void fwav_atran_z(fwav fw,float *b0,int dx,int dy,int dz)
{
int j,dz2,y,z,dd,d;
int j/*,dz2*/,y,z,dd/*,d*/;
float *ba0,*ba1,*ba2,*bb,v1,td0,td1;
td0=fw->td0; td1=fw->td1;
dz2=HALF(dz); dd=dx*dy; d=dx*dy*dz2;
/*dz2=HALF(dz);*/ dd=dx*dy; /*d=dx*dy*dz2;*/
bb=fw->bt;
for (z=0;z+1<dz;z+=2) {
for (y=0;y<dy;y++) {
......
......@@ -79,6 +79,7 @@ fail.c
comm.c
gs_local.c
findpts_local.c
mem.c
ext/findpts_local_ext.c
)
......
......@@ -16,6 +16,129 @@ uint comm_gbl_id=0, comm_gbl_np=1;
GS_DEFINE_IDENTITIES()
GS_DEFINE_DOM_SIZES()
void comm_init(struct comm *c, comm_ext ce)
{
#ifdef MPI
int i;
MPI_Comm_dup(ce, &c->c);
MPI_Comm_rank(c->c,&i), comm_gbl_id=c->id=i;
MPI_Comm_size(c->c,&i), comm_gbl_np=c->np=i;
#else
c->id = 0, c->np = 1;
#endif
}
void comm_init_check_(struct comm *c, MPI_Fint ce, uint np,
const char *file, unsigned line)
{
#ifdef MPI
comm_init(c,MPI_Comm_f2c(ce));
if(c->np != np)
fail(1,file,line,"comm_init_check: passed P=%u, "
"but MPI_Comm_size gives P=%u",
(unsigned)np,(unsigned)c->np);
#else
comm_init(c,0);
if(np != 1)
fail(1,file,line,"comm_init_check: passed P=%u, "
"but not compiled with -DMPI",(unsigned)np);
#endif
}
#define comm_init_check(c,ce,np) comm_init_check_(c,ce,np,__FILE__,__LINE__)
void comm_dup_(struct comm *d, const struct comm *s,
const char *file, unsigned line)
{
d->id = s->id, d->np = s->np;
#ifdef MPI
MPI_Comm_dup(s->c,&d->c);
#else
if(s->np!=1) fail(1,file,line,"%s not compiled with -DMPI\n",file);
#endif
}
#define comm_dup(d,s) comm_dup_(d,s,__FILE__,__LINE__)
void comm_free(struct comm *c)
{
#ifdef MPI
MPI_Comm_free(&c->c);
#endif
}
double comm_time(void)
{
#ifdef MPI
return MPI_Wtime();
#else
return 0;
#endif
}
void comm_barrier(const struct comm *c)
{
#ifdef MPI
MPI_Barrier(c->c);
#endif
}
void comm_recv(const struct comm *c, void *p, size_t n,
uint src, int tag)
{
#ifdef MPI
# ifndef MPI_STATUS_IGNORE
MPI_Status stat;
MPI_Recv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->c,&stat);
# else
MPI_Recv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->c,MPI_STATUS_IGNORE);
# endif
#endif
}
void comm_send(const struct comm *c, void *p, size_t n,
uint dst, int tag)
{
#ifdef MPI
MPI_Send(p,n,MPI_UNSIGNED_CHAR,dst,tag,c->c);
#endif
}
void comm_irecv(comm_req *req, const struct comm *c,
void *p, size_t n, uint src, int tag)
{
#ifdef MPI
MPI_Irecv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->c,req);
#endif
}
void comm_isend(comm_req *req, const struct comm *c,
void *p, size_t n, uint dst, int tag)
{
#ifdef MPI
MPI_Isend(p,n,MPI_UNSIGNED_CHAR,dst,tag,c->c,req);
#endif
}
void comm_wait(comm_req *req, int n)
{
#ifdef MPI
# ifndef MPI_STATUSES_IGNORE
MPI_Status status[8];
while(n>=8) MPI_Waitall(8,req,status), req+=8, n-=8;
if(n>0) MPI_Waitall(n,req,status);
# else
MPI_Waitall(n,req,MPI_STATUSES_IGNORE);
# endif
#endif
}
void comm_bcast(const struct comm *c, void *p, size_t n, uint root)
{
#ifdef MPI
MPI_Bcast(p,n,MPI_UNSIGNED_CHAR,root,c->c);
#endif
}
static void scan_imp(void *scan, const struct comm *com, gs_dom dom, gs_op op,
const void *v, uint vn, void *buffer)
{
......@@ -64,7 +187,7 @@ static void scan_imp(void *scan, const struct comm *com, gs_dom dom, gs_op op,
}
static void allreduce_imp(const struct comm *com, gs_dom dom, gs_op op,
void allreduce_imp(const struct comm *com, gs_dom dom, gs_op op,
void *v, uint vn, void *buf)
{
size_t total_size = vn*gs_dom_size[dom];
......
......@@ -87,21 +87,21 @@ struct comm {
comm_ext c;
};
static void comm_init(struct comm *c, comm_ext ce);
void comm_init(struct comm *c, comm_ext ce);
/* (macro) static void comm_init_check(struct comm *c, MPI_Fint ce, uint np); */
/* (macro) static void comm_dup(struct comm *d, const struct comm *s); */
static void comm_free(struct comm *c);
static double comm_time(void);
static void comm_barrier(const struct comm *c);
static void comm_recv(const struct comm *c, void *p, size_t n,
void comm_free(struct comm *c);
double comm_time(void);
void comm_barrier(const struct comm *c);
void comm_recv(const struct comm *c, void *p, size_t n,
uint src, int tag);
static void comm_send(const struct comm *c, void *p, size_t n,
void comm_send(const struct comm *c, void *p, size_t n,
uint dst, int tag);
static void comm_irecv(comm_req *req, const struct comm *c,
void comm_irecv(comm_req *req, const struct comm *c,
void *p, size_t n, uint src, int tag);
static void comm_isend(comm_req *req, const struct comm *c,
void comm_isend(comm_req *req, const struct comm *c,
void *p, size_t n, uint dst, int tag);
static void comm_wait(comm_req *req, int n);
void comm_wait(comm_req *req, int n);
double comm_dot(const struct comm *comm, double *v, double *w, uint n);
......@@ -114,7 +114,7 @@ void comm_scan(void *scan, const struct comm *com, gs_dom dom, gs_op op,
#define DEFINE_REDUCE(T) \
T PREFIXED_NAME(comm_reduce__##T)( \
const struct comm *comm, gs_op op, const T *in, uint n); \
static T comm_reduce_##T(const struct comm *c, gs_op op, const T *v, uint vn) \
T comm_reduce_##T(const struct comm *c, gs_op op, const T *v, uint vn) \
{ return PREFIXED_NAME(comm_reduce__##T)(c,op,v,vn); }
GS_FOR_EACH_DOMAIN(DEFINE_REDUCE)
#undef DEFINE_REDUCE
......@@ -125,132 +125,4 @@ GS_FOR_EACH_DOMAIN(DEFINE_REDUCE)
TYPE_GLOBAL(comm_reduce_int,comm_reduce_long,comm_reduce_long_long)
#endif
/*----------------------------------------------------------------------------
Code for static (inline) functions
----------------------------------------------------------------------------*/
static void comm_init(struct comm *c, comm_ext ce)
{
#ifdef MPI
int i;
MPI_Comm_dup(ce, &c->c);
MPI_Comm_rank(c->c,&i), comm_gbl_id=c->id=i;
MPI_Comm_size(c->c,&i), comm_gbl_np=c->np=i;
#else
c->id = 0, c->np = 1;
#endif
}
static void comm_init_check_(struct comm *c, MPI_Fint ce, uint np,
const char *file, unsigned line)
{
#ifdef MPI
comm_init(c,MPI_Comm_f2c(ce));
if(c->np != np)
fail(1,file,line,"comm_init_check: passed P=%u, "
"but MPI_Comm_size gives P=%u",
(unsigned)np,(unsigned)c->np);
#else
comm_init(c,0);
if(np != 1)
fail(1,file,line,"comm_init_check: passed P=%u, "
"but not compiled with -DMPI",(unsigned)np);
#endif
}
#define comm_init_check(c,ce,np) comm_init_check_(c,ce,np,__FILE__,__LINE__)
static void comm_dup_(struct comm *d, const struct comm *s,
const char *file, unsigned line)
{
d->id = s->id, d->np = s->np;
#ifdef MPI
MPI_Comm_dup(s->c,&d->c);
#else
if(s->np!=1) fail(1,file,line,"%s not compiled with -DMPI\n",file);
#endif
}
#define comm_dup(d,s) comm_dup_(d,s,__FILE__,__LINE__)
static void comm_free(struct comm *c)
{
#ifdef MPI
MPI_Comm_free(&c->c);
#endif
}
static double comm_time(void)
{
#ifdef MPI
return MPI_Wtime();
#else
return 0;
#endif
}
static void comm_barrier(const struct comm *c)
{
#ifdef MPI
MPI_Barrier(c->c);
#endif
}
static void comm_recv(const struct comm *c, void *p, size_t n,
uint src, int tag)
{
#ifdef MPI
# ifndef MPI_STATUS_IGNORE
MPI_Status stat;
MPI_Recv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->c,&stat);
# else
MPI_Recv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->c,MPI_STATUS_IGNORE);
# endif
#endif
}
static void comm_send(const struct comm *c, void *p, size_t n,
uint dst, int tag)
{
#ifdef MPI
MPI_Send(p,n,MPI_UNSIGNED_CHAR,dst,tag,c->c);
#endif
}
static void comm_irecv(comm_req *req, const struct comm *c,
void *p, size_t n, uint src, int tag)
{
#ifdef MPI
MPI_Irecv(p,n,MPI_UNSIGNED_CHAR,src,tag,c->c,req);
#endif
}
static void comm_isend(comm_req *req, const struct comm *c,
void *p, size_t n, uint dst, int tag)
{
#ifdef MPI
MPI_Isend(p,n,MPI_UNSIGNED_CHAR,dst,tag,c->c,req);
#endif
}
static void comm_wait(comm_req *req, int n)
{
#ifdef MPI
# ifndef MPI_STATUSES_IGNORE
MPI_Status status[8];
while(n>=8) MPI_Waitall(8,req,status), req+=8, n-=8;
if(n>0) MPI_Waitall(n,req,status);
# else
MPI_Waitall(n,req,MPI_STATUSES_IGNORE);
# endif
#endif
}
static void comm_bcast(const struct comm *c, void *p, size_t n, uint root)
{
#ifdef MPI
MPI_Bcast(p,n,MPI_UNSIGNED_CHAR,root,c->c);
#endif
}
#endif
......@@ -48,17 +48,11 @@ void findpts_el_eval_2(
const double *const r_base, const unsigned r_stride, const unsigned pn,
const double *const in, struct findpts_el_data_2 *const fd);
static void findpts_el_start_2(struct findpts_el_data_2 *const fd,
const double *const x[2])
{
fd->side_init=0,fd->x[0]=x[0],fd->x[1]=x[1];
}
static struct findpts_el_pt_2 *findpts_el_points_2(
struct findpts_el_data_2 *const fd)
{
return fd->p;
}
void findpts_el_start_2(struct findpts_el_data_2 *const fd,
const double *const x[2]);
struct findpts_el_pt_2 *findpts_el_points_2(
struct findpts_el_data_2 *const fd);
#define findpts_el_setup_3 PREFIXED_NAME(findpts_el_setup_3)
#define findpts_el_free_3 PREFIXED_NAME(findpts_el_free_3 )
......@@ -107,16 +101,10 @@ void findpts_el_eval_3(
const double *const r_base, const unsigned r_stride, const unsigned pn,
const double *const in, struct findpts_el_data_3 *const fd);
static void findpts_el_start_3(struct findpts_el_data_3 *const fd,
const double *const x[3])
{
fd->side_init=0,fd->x[0]=x[0],fd->x[1]=x[1],fd->x[2]=x[2];
}
static struct findpts_el_pt_3 *findpts_el_points_3(
struct findpts_el_data_3 *const fd)
{
return fd->p;
}
void findpts_el_start_3(struct findpts_el_data_3 *const fd,
const double *const x[3]);
struct findpts_el_pt_3 *findpts_el_points_3(
struct findpts_el_data_3 *const fd);
#endif
......@@ -191,6 +191,19 @@ void findpts_el_setup_2(struct findpts_el_data_2 *const fd,
fd->edge[3].dxdn[d] = fd->sides + 8*ns + (2+d)*nr;
}
void findpts_el_start_2(struct findpts_el_data_2 *const fd,
const double *const x[2])
{
fd->side_init=0,fd->x[0]=x[0],fd->x[1]=x[1];
}
struct findpts_el_pt_2 *findpts_el_points_2(
struct findpts_el_data_2 *const fd)
{
return fd->p;
}
void findpts_el_free_2(struct findpts_el_data_2 *const fd)
{
free(fd->p);
......
......@@ -280,6 +280,18 @@ void findpts_el_setup_3(struct findpts_el_data_3 *const fd,
#undef SET_EDGE1
}
void findpts_el_start_3(struct findpts_el_data_3 *const fd,
const double *const x[3])
{
fd->side_init=0,fd->x[0]=x[0],fd->x[1]=x[1],fd->x[2]=x[2];
}
struct findpts_el_pt_3 *findpts_el_points_3(
struct findpts_el_data_3 *const fd)
{
return fd->p;
}
void findpts_el_free_3(struct findpts_el_data_3 *const fd)
{
free(fd->p);
......
#include <stddef.h>
#include <stdlib.h>
#include <math.h> /* for cos, fabs */
#include <float.h>
#include <string.h>
#include "c99.h"
#include "name.h"
#include "fail.h"
#include "mem.h"
void *smalloc(size_t size, const char *file, unsigned line)
{
void *restrict res = malloc(size);
#if PRINT_MALLOCS
fprintf(stdout,"MEM: proc %04d: %p = malloc(%ld) @ %s(%u)\n",
(int)comm_gbl_id,res,(long)size,file,line), fflush(stdout);
#endif
if(!res && size)
fail(1,file,line,"allocation of %ld bytes failed\n",(long)size);
return res;
}
void *scalloc(
size_t nmemb, size_t size, const char *file, unsigned line)
{
void *restrict res = calloc(nmemb, size);
#if PRINT_MALLOCS
fprintf(stdout,"MEM: proc %04d: %p = calloc(%ld) @ %s(%u)\n",
(int)comm_gbl_id,res,(long)size*nmemb,file,line), fflush(stdout);
#endif
if(!res && nmemb)
fail(1,file,line,"allocation of %ld bytes failed\n",
(long)size*nmemb);
return res;
}
void *srealloc(
void *restrict ptr, size_t size, const char *file, unsigned line)
{
void *restrict res = realloc(ptr, size);
#if PRINT_MALLOCS
if(res!=ptr) {
if(ptr)
fprintf(stdout,"MEM: proc %04d: %p freed by realloc @ %s(%u)\n",
(int)comm_gbl_id,ptr,file,line), fflush(stdout);
fprintf(stdout,"MEM: proc %04d: %p = realloc of %p to %lu @ %s(%u)\n",
(int)comm_gbl_id,res,ptr,(long)size,file,line), fflush(stdout);
} else
fprintf(stdout,"MEM: proc %04d: %p realloc'd to %lu @ %s(%u)\n",
(int)comm_gbl_id,res,(long)size,file,line), fflush(stdout);
#endif
if(!res && size)
fail(1,file,line,"allocation of %ld bytes failed\n",(long)size);
return res;
}
#if PRINT_MALLOCS
void sfree(void *restrict ptr, const char *file, unsigned line)
{
free(ptr);
fprintf(stdout,"MEM: proc %04d: %p freed @ %s(%u)\n",
(int)comm_gbl_id,ptr,file,line), fflush(stdout);
}
#endif
void array_init_(struct array *a, size_t max, size_t size,
const char *file, unsigned line)
{
a->n=0, a->max=max, a->ptr=smalloc(max*size,file,line);
}
void array_resize_(struct array *a, size_t max, size_t size,
const char *file, unsigned line)
{
a->max=max, a->ptr=srealloc(a->ptr,max*size,file,line);
}
void *array_reserve_(struct array *a, size_t min, size_t size,
const char *file, unsigned line)
{
size_t max = a->max;
if(max<min) {
max+=max/2+1;
if(max<min) max=min;
array_resize_(a,max,size,file,line);
}
return a->ptr;
}
void array_cat_(size_t size, struct array *d, const void *s, size_t n,
const char *file, unsigned line)
{
char *out = array_reserve_(d,d->n+n,size, file,line);
memcpy(out+d->n*size, s, n*size);
d->