Browse Source

xml_string_length and xml_string_copy will now accept 0 as string

master
ooxi 12 years ago
parent
commit
2be4cfa787
2 changed files with 8 additions and 1 deletions
  1. +1
    -1
      CMakeLists.txt
  2. +7
    -0
      src/xml.c

+ 1
- 1
CMakeLists.txt View File

@@ -2,7 +2,7 @@
PROJECT(xml) PROJECT(xml)
SET(VERSION_MAJOR "0") SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "1") SET(VERSION_MINOR "1")
SET(VERSION_PATCH "1")
SET(VERSION_PATCH "2")
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)


+ 7
- 0
src/xml.c View File

@@ -719,6 +719,9 @@ struct xml_node* xml_node_child(struct xml_node* node, size_t child) {
* [PUBLIC API] * [PUBLIC API]
*/ */
size_t xml_string_length(struct xml_string* string) { size_t xml_string_length(struct xml_string* string) {
if (!string) {
return 0;
}
return string->length; return string->length;
} }


@@ -728,6 +731,10 @@ size_t xml_string_length(struct xml_string* string) {
* [PUBLIC API] * [PUBLIC API]
*/ */
void xml_string_copy(struct xml_string* string, uint8_t* buffer, size_t length) { void xml_string_copy(struct xml_string* string, uint8_t* buffer, size_t length) {
if (!string) {
return;
}

#define min(X,Y) ((X) < (Y) ? (X) : (Y)) #define min(X,Y) ((X) < (Y) ? (X) : (Y))
length = min(length, string->length); length = min(length, string->length);
#undef min #undef min


Loading…
Cancel
Save