libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-region.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2026 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
53
55typedef struct lws_region_claim {
56 const uint8_t *s; /* NULL: slot free */
57 const uint8_t *e;
58 const char *who;
59 uint16_t gen; /* distinguishes reuses of the slot */
61
71
72/* lws_region_init() flags */
73#define LWS_REGION_F_ABORT (1 << 0) /* abort() on violation */
74
75/* lws_region_claim() results other than a handle */
76enum {
77 LWS_REGION_NOT_TRACKED = -1, /* p is not in the buffer */
78 LWS_REGION_E_OVERRUN = -2, /* runs past the end */
79 LWS_REGION_E_OVERLAP = -3, /* overlaps a live claim */
80 LWS_REGION_E_FULL = -4, /* no free claim slot */
81};
82
97lws_region_init(lws_region_t *r, const char *name, const void *base,
98 size_t len, lws_region_claim_t *claims, size_t count_claims,
99 unsigned int flags);
100
115lws_region_claim(lws_region_t *r, const void *p, size_t len, const char *who);
116
129
141
152lws_region_trim(lws_region_t *r, const void *p);
153
164lws_region_idle(const lws_region_t *r, const char *where);
165
uint8_t count_claims
Definition lws-region.h:68
lws_region_claim_t * claims
Definition lws-region.h:67
const uint8_t * base
Definition lws-region.h:65
const uint8_t * e
Definition lws-region.h:57
const char * who
Definition lws-region.h:58
const char * name
Definition lws-region.h:64
uint8_t flags
Definition lws-region.h:69
size_t len
Definition lws-region.h:66
const uint8_t * s
Definition lws-region.h:56
LWS_VISIBLE LWS_EXTERN void lws_region_release_containing(lws_region_t *r, const void *p)
struct lws_region lws_region_t
LWS_VISIBLE LWS_EXTERN void lws_region_trim(lws_region_t *r, const void *p)
LWS_VISIBLE LWS_EXTERN void lws_region_release(lws_region_t *r, int handle)
LWS_VISIBLE LWS_EXTERN int lws_region_idle(const lws_region_t *r, const char *where)
LWS_VISIBLE LWS_EXTERN int lws_region_claim(lws_region_t *r, const void *p, size_t len, const char *who)
LWS_VISIBLE LWS_EXTERN int lws_region_init(lws_region_t *r, const char *name, const void *base, size_t len, lws_region_claim_t *claims, size_t count_claims, unsigned int flags)
struct lws_region_claim lws_region_claim_t
@ LWS_REGION_E_OVERLAP
Definition lws-region.h:79
@ LWS_REGION_E_OVERRUN
Definition lws-region.h:78
@ LWS_REGION_E_FULL
Definition lws-region.h:80
@ LWS_REGION_NOT_TRACKED
Definition lws-region.h:77
unsigned short uint16_t
#define LWS_EXTERN
unsigned char uint8_t
#define LWS_VISIBLE