php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
mysqlnd_read_buffer.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Andrey Hristov <andrey@php.net> |
14 | Ulf Wendel <uw@php.net> |
15 +----------------------------------------------------------------------+
16*/
17
18#include "php.h"
19#include "mysqlnd.h"
20#include "mysqlnd_debug.h"
21#include "mysqlnd_read_buffer.h"
22
23
24/* {{{ mysqlnd_read_buffer_is_empty */
25static bool
26mysqlnd_read_buffer_is_empty(const MYSQLND_READ_BUFFER * const buffer)
27{
28 return buffer->len? FALSE:TRUE;
29}
30/* }}} */
31
32
33/* {{{ mysqlnd_read_buffer_read */
34static void
35mysqlnd_read_buffer_read(MYSQLND_READ_BUFFER * buffer, const size_t count, zend_uchar * dest)
36{
37 if (buffer->len >= count) {
38 memcpy(dest, buffer->data + buffer->offset, count);
39 buffer->offset += count;
40 buffer->len -= count;
41 }
42}
43/* }}} */
44
45
46/* {{{ mysqlnd_read_buffer_bytes_left */
47static size_t
48mysqlnd_read_buffer_bytes_left(const MYSQLND_READ_BUFFER * const buffer)
49{
50 return buffer->len;
51}
52/* }}} */
53
54
55/* {{{ mysqlnd_read_buffer_free */
56static void
57mysqlnd_read_buffer_free(MYSQLND_READ_BUFFER ** buffer)
58{
59 DBG_ENTER("mysqlnd_read_buffer_free");
60 if (*buffer) {
61 mnd_efree((*buffer)->data);
63 *buffer = NULL;
64 }
66}
67/* }}} */
68
69
70/* {{{ mysqlnd_create_read_buffer */
73{
75 DBG_ENTER("mysqlnd_create_read_buffer");
76 ret->is_empty = mysqlnd_read_buffer_is_empty;
77 ret->read = mysqlnd_read_buffer_read;
78 ret->bytes_left = mysqlnd_read_buffer_bytes_left;
79 ret->free_buffer = mysqlnd_read_buffer_free;
80 ret->data = mnd_emalloc(count);
81 ret->size = ret->len = count;
82 ret->offset = 0;
84}
85/* }}} */
count(Countable|array $value, int $mode=COUNT_NORMAL)
memcpy(ptr1, ptr2, size)
#define TRUE
Definition gd_gd.c:7
#define FALSE
Definition gd_gd.c:8
#define NULL
Definition gdcache.h:45
#define mnd_efree(ptr)
#define mnd_emalloc(size)
#define DBG_VOID_RETURN
#define DBG_RETURN(value)
PHPAPI MYSQLND_READ_BUFFER * mysqlnd_create_read_buffer(const size_t count)
struct st_mysqlnd_read_buffer MYSQLND_READ_BUFFER
#define PHPAPI
Definition php.h:71
Definition file.h:177
unsigned char zend_uchar
Definition zend_types.h:57
zval * ret