1
0
mirror of https://github.com/php/php-src.git synced 2026-03-29 19:52:20 +02:00

const-ify fields

This commit is contained in:
Andrey Hristov
2010-04-28 12:29:13 +00:00
parent 9fac561399
commit 16d5d5966e
3 changed files with 11 additions and 12 deletions

View File

@@ -63,12 +63,12 @@ typedef struct st_mysqlnd_cmd_buffer
typedef struct st_mysqlnd_field
{
char *name; /* Name of column */
char *org_name; /* Original column name, if an alias */
char *table; /* Table of column if column was a field */
char *org_table; /* Org table name, if table was an alias */
char *db; /* Database for table */
char *catalog; /* Catalog for table */
const char *name; /* Name of column */
const char *org_name; /* Original column name, if an alias */
const char *table; /* Table of column if column was a field */
const char *org_table; /* Org table name, if table was an alias */
const char *db; /* Database for table */
const char *catalog; /* Catalog for table */
char *def; /* Default value (set by mysql_list_fields) */
unsigned long length; /* Width of column (create length) */
unsigned long max_length; /* Max width for selected set */

View File

@@ -70,7 +70,7 @@
static const char *unknown_sqlstate= "HY000";
char * const mysqlnd_empty_string = "";
const char * const mysqlnd_empty_string = "";
/* Used in mysqlnd_debug.c */
const char mysqlnd_read_header_name[] = "mysqlnd_read_header";
@@ -927,13 +927,13 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
BAIL_IF_NO_MORE_DATA;
switch ((len)) {
case 0:
*(char **)(((char*)meta) + rset_field_offsets[i]) = mysqlnd_empty_string;
*(const char **)(((char*)meta) + rset_field_offsets[i]) = mysqlnd_empty_string;
*(unsigned int *)(((char*)meta) + rset_field_offsets[i+1]) = 0;
break;
case MYSQLND_NULL_LENGTH:
goto faulty_or_fake;
default:
*(char **)(((char *)meta) + rset_field_offsets[i]) = (char *)p;
*(const char **)(((char *)meta) + rset_field_offsets[i]) = (const char *)p;
*(unsigned int *)(((char*)meta) + rset_field_offsets[i+1]) = len;
p += len;
total_len += len + 1;
@@ -989,6 +989,7 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
(len = php_mysqlnd_net_field_length(&p)) &&
len != MYSQLND_NULL_LENGTH)
{
BAIL_IF_NO_MORE_DATA;
DBG_INF_FMT("Def found, length %lu, persistent=%d", len, packet->persistent_alloc);
meta->def = mnd_pemalloc(len + 1, packet->persistent_alloc);
memcpy(meta->def, p, len);
@@ -997,8 +998,6 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
p += len;
}
BAIL_IF_NO_MORE_DATA;
DBG_INF_FMT("allocing root. persistent=%d", packet->persistent_alloc);
root_ptr = meta->root = mnd_pemalloc(total_len, packet->persistent_alloc);
meta->root_len = total_len;

View File

@@ -254,7 +254,7 @@ PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * c
unsigned long php_mysqlnd_net_field_length(zend_uchar **packet);
zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length);
PHPAPI extern char * const mysqlnd_empty_string;
PHPAPI const extern char * const mysqlnd_empty_string;
void php_mysqlnd_rowp_read_binary_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval ** fields,