MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_vstring_mmap_alloc2

Function acl_vstring_mmap_alloc2

lib_acl/src/stdlib/acl_vstring.c:346–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344static acl_pthread_once_t __once_control = ACL_PTHREAD_ONCE_INIT;
345
346ACL_VSTRING *acl_vstring_mmap_alloc2(ACL_FILE_HANDLE fd,
347 size_t max_len, size_t init_len, size_t offset)
348{
349 const char *myname = "acl_vstring_mmap_alloc";
350 ACL_VSTRING *vp;
351
352 if (init_len < 1) {
353 acl_msg_panic("%s: bad length %ld", myname, (long) init_len);
354 }
355
356 if (offset > 0) {
357 int n = offset % __page_size == 0 ? 0 : 1;
358 acl_pthread_once(&__once_control, get_pagesize);
359 offset = (n + offset / __page_size) * __page_size;
360 }
361
362 if (max_len < init_len) {
363 max_len = init_len;
364 }
365
366 if (max_len < offset) {
367 max_len = offset;
368 }
369
370 vp = (ACL_VSTRING *) acl_mymalloc(sizeof(*vp));
371
372
373 vp->vbuf.flags = ACL_VBUF_FLAG_MMAP;
374 vp->vbuf.len = init_len;
375#if 0
376 vp->vbuf.get_ready = acl_vstring_get_ready;
377 vp->vbuf.put_ready = acl_vstring_put_ready;
378 vp->vbuf.space = acl_vstring_space;
379#endif
380 vp->maxlen = max_len;
381 vp->vbuf.alloc.slice = NULL;
382 vp->vbuf.fd = fd;
383#if defined(_WIN32) || defined(_WIN64)
384 vp->vbuf.hmap = NULL;
385#endif
386
387 mmap_buf_init(vp, offset);
388
389 ACL_VSTRING_RESET(vp);
390 vp->vbuf.data[0] = 0;
391 return vp;
392}
393
394/* acl_vstring_free - destroy variable-length string */
395

Callers 2

acl_vstring_mmap_allocFunction · 0.85
stringMethod · 0.85

Calls 3

acl_msg_panicFunction · 0.85
acl_pthread_onceFunction · 0.85
mmap_buf_initFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…