⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ringqopen.htm

📁 goahead是linux下的轻量级web服务器
💻 HTM
字号:
<html>
<head>
<title>ringqOpen -- basic</title>
<link rel="stylesheet" href="../../../style/doc.htm" type="text/css">
</head>

<body>
 
<table border=0 width=100% cellspacing=0 cellpadding=0>
<tr>
	<td class=title-left><b> ringqOpen</b></td>
    <td class=title-center><b> basic</b></td>
    <td class=title-right><B> EMF</B></td>
</tr>
</table>

<hr>
<h2>Synopsis</h2>
<p>Create a new ring queue for dynamic strings</p>

<h2>Prototype</h2>

<pre>
int <b>ringqOpen</b>(ringq_t *rq, int increment, int maxsize); 
</pre>

<h2>Parameters</h2>
<p>
<table width=90%>
    
    <tr>
        <td width=40>rq</td>
        <td>Pointer to a ringq_t struct that receives the new ring queue</td>
	</tr>
    <tr>
        <td width=40>increment</td>
        <td>The amount to increase the size of the ringq should it need to grow</td>
	</tr>
    <tr>
        <td width=40>maxsize</td>
        <td>The upper limit beyond which the queue must not grow</td>
	</tr>
</table>
</p>

<h2>Description</h2>

<p><pre>
A ring queue allows maximum utilization of memory for data storage and is
ideal for input/output buffering.  This module provides a highly effecient
implementation and a vehicle for dynamic strings.

WARNING:  This is a public implementation and callers have full access to
the queue structure and pointers.  Change this module very carefully.

This module follows the open/close model.

Operation of a ringq where rq is a pointer to a ringq :

	rq->buflen contains the size of the buffer.
	rq->buf will point to the start of the buffer.
	rq->servp will point to the first (un-consumed) data byte.
	rq->endp will point to the next free location to which new data is added
	rq->endbuf will point to one past the end of the buffer.

Eg. If the ringq contains the data "abcdef", it might look like :

+-------------------------------------------------------------------+
 |   |   |   |   |   |   |   | a | b | c | d | e | f |   |   |   |   |
+-------------------------------------------------------------------+
   ^                           ^                       ^               ^
   |                           |                       |               |
 rq->buf                    rq->servp               rq->endp      rq->enduf
    
The queue is empty when servp == endp.  This means that the queue will hold
at most rq->buflen -1 bytes.  It is the fillers responsibility to ensure
the ringq is never filled such that servp == endp.

It is the fillers responsibility to "wrap" the endp back to point to
rq->buf when the pointer steps past the end.  Correspondingly it is the
consumers responsibility to "wrap" the servp when it steps to rq->endbuf.
The ringqPutc and ringqGetc routines will do this automatically.
</pre></p>

<h2>Return Value</h2>
<p> 
0 on success, -1 on error.
</p>

<h2>Example</h2>
<pre>
</pre>

<h2>See Also</h2>
<p>
<a href="ringqPutBlk.htm">ringqPutBlk</a>,
<a href="ringqPutStr.htm">ringqPutStr</a>,
<a href="ringqPutc.htm">ringqPutc</a>
</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -