8 static int strs(Tcl_Interp *ip, int strc, Tcl_Obj *const *strv, int *l_r) {
12 for (i=1; i<strc; i++) {
13 rc= Tcl_ConvertToType(ip,strv[i],&hbytes_type);
15 l += HBYTES_LEN(HBYTES(strv[i]));
21 int app_pre(ClientData cd, Tcl_Interp *ip, int begin,
22 HBytes_Var v, int strc, Tcl_Obj *const *strv) {
23 int ol, rc, al, i, tl;
25 rc= strs(ip,strc,strv,&al); if (rc) return rc;
27 ol= HBYTES_LEN(*v.hb);
28 v.hb->start= v.hb->end= Tcl_Realloc(v.hb->start, ol + al);
30 if (begin) v.hb->end += ol;
31 else memmove(v.hb->start + al, v.hb->start, ol);
33 for (i=1; i<strc; i++) {
34 tl= HBYTES_LEN(HBYTES(strv[i]));
35 memcpy(v.hb->end, HBYTES(strv[i]).start, tl);
41 int do_hbytes_append(ClientData cd, Tcl_Interp *ip,
42 HBytes_Var v, int strc, Tcl_Obj *const *strv) {
43 return app_pre(cd,ip,1,v,strc,strv);
46 int do_hbytes_prepend(ClientData cd, Tcl_Interp *ip,
47 HBytes_Var v, int strc, Tcl_Obj *const *strv) {
48 return app_pre(cd,ip,0,v,strc,strv);
51 int do_hbytes_concat(ClientData cd, Tcl_Interp *ip,
52 int strc, Tcl_Obj *const *strv, HBytes_Value *result) {
55 result->start= result->end= 0;
57 return app_pre(cd,ip,1,fake,strc,strv);