Lines Matching refs:s

40 void Curl_dyn_init(struct dynbuf *s, size_t toobig)  in Curl_dyn_init()  argument
42 DEBUGASSERT(s); in Curl_dyn_init()
44 s->bufr = NULL; in Curl_dyn_init()
45 s->leng = 0; in Curl_dyn_init()
46 s->allc = 0; in Curl_dyn_init()
47 s->toobig = toobig; in Curl_dyn_init()
49 s->init = DYNINIT; in Curl_dyn_init()
57 void Curl_dyn_free(struct dynbuf *s) in Curl_dyn_free() argument
59 DEBUGASSERT(s); in Curl_dyn_free()
60 Curl_safefree(s->bufr); in Curl_dyn_free()
61 s->leng = s->allc = 0; in Curl_dyn_free()
67 static CURLcode dyn_nappend(struct dynbuf *s, in dyn_nappend() argument
70 size_t indx = s->leng; in dyn_nappend()
71 size_t a = s->allc; in dyn_nappend()
75 DEBUGASSERT(s->init == DYNINIT); in dyn_nappend()
76 DEBUGASSERT(s->toobig); in dyn_nappend()
77 DEBUGASSERT(indx < s->toobig); in dyn_nappend()
78 DEBUGASSERT(!s->leng || s->bufr); in dyn_nappend()
79 DEBUGASSERT(a <= s->toobig); in dyn_nappend()
82 if(fit > s->toobig) { in dyn_nappend()
83 Curl_dyn_free(s); in dyn_nappend()
89 if(MIN_FIRST_ALLOC > s->toobig) in dyn_nappend()
90 a = s->toobig; in dyn_nappend()
99 if(a > s->toobig) in dyn_nappend()
101 a = s->toobig; in dyn_nappend()
104 if(a != s->allc) { in dyn_nappend()
107 void *p = realloc(s->bufr, a); in dyn_nappend()
109 Curl_dyn_free(s); in dyn_nappend()
112 s->bufr = p; in dyn_nappend()
113 s->allc = a; in dyn_nappend()
117 memcpy(&s->bufr[indx], mem, len); in dyn_nappend()
118 s->leng = indx + len; in dyn_nappend()
119 s->bufr[s->leng] = 0; in dyn_nappend()
127 void Curl_dyn_reset(struct dynbuf *s) in Curl_dyn_reset() argument
129 DEBUGASSERT(s); in Curl_dyn_reset()
130 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_reset()
131 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_reset()
132 if(s->leng) in Curl_dyn_reset()
133 s->bufr[0] = 0; in Curl_dyn_reset()
134 s->leng = 0; in Curl_dyn_reset()
141 CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail) in Curl_dyn_tail() argument
143 DEBUGASSERT(s); in Curl_dyn_tail()
144 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_tail()
145 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_tail()
146 if(trail > s->leng) in Curl_dyn_tail()
148 else if(trail == s->leng) in Curl_dyn_tail()
151 Curl_dyn_reset(s); in Curl_dyn_tail()
154 memmove(&s->bufr[0], &s->bufr[s->leng - trail], trail); in Curl_dyn_tail()
155 s->leng = trail; in Curl_dyn_tail()
156 s->bufr[s->leng] = 0; in Curl_dyn_tail()
165 CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len) in Curl_dyn_addn() argument
167 DEBUGASSERT(s); in Curl_dyn_addn()
168 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_addn()
169 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_addn()
170 return dyn_nappend(s, mem, len); in Curl_dyn_addn()
176 CURLcode Curl_dyn_add(struct dynbuf *s, const char *str) in Curl_dyn_add() argument
180 DEBUGASSERT(s); in Curl_dyn_add()
181 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_add()
182 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_add()
184 return dyn_nappend(s, (unsigned char *)str, n); in Curl_dyn_add()
190 CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap) in Curl_dyn_vaddf() argument
194 DEBUGASSERT(s); in Curl_dyn_vaddf()
195 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_vaddf()
196 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_vaddf()
198 rc = Curl_dyn_vprintf(s, fmt, ap); in Curl_dyn_vaddf()
210 CURLcode result = dyn_nappend(s, (unsigned char *)str, strlen(str)); in Curl_dyn_vaddf()
215 Curl_dyn_free(s); in Curl_dyn_vaddf()
223 CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...) in Curl_dyn_addf() argument
227 DEBUGASSERT(s); in Curl_dyn_addf()
228 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_addf()
229 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_addf()
231 result = Curl_dyn_vaddf(s, fmt, ap); in Curl_dyn_addf()
239 char *Curl_dyn_ptr(const struct dynbuf *s) in Curl_dyn_ptr() argument
241 DEBUGASSERT(s); in Curl_dyn_ptr()
242 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_ptr()
243 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_ptr()
244 return s->bufr; in Curl_dyn_ptr()
250 unsigned char *Curl_dyn_uptr(const struct dynbuf *s) in Curl_dyn_uptr() argument
252 DEBUGASSERT(s); in Curl_dyn_uptr()
253 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_uptr()
254 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_uptr()
255 return (unsigned char *)s->bufr; in Curl_dyn_uptr()
261 size_t Curl_dyn_len(const struct dynbuf *s) in Curl_dyn_len() argument
263 DEBUGASSERT(s); in Curl_dyn_len()
264 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_len()
265 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_len()
266 return s->leng; in Curl_dyn_len()
272 CURLcode Curl_dyn_setlen(struct dynbuf *s, size_t set) in Curl_dyn_setlen() argument
274 DEBUGASSERT(s); in Curl_dyn_setlen()
275 DEBUGASSERT(s->init == DYNINIT); in Curl_dyn_setlen()
276 DEBUGASSERT(!s->leng || s->bufr); in Curl_dyn_setlen()
277 if(set > s->leng) in Curl_dyn_setlen()
279 s->leng = set; in Curl_dyn_setlen()
280 s->bufr[s->leng] = 0; in Curl_dyn_setlen()