change NewWithCString to allocate room for the terminating NULL, so the data
can be treated as a cstring (duh). git-svn-id: http://skia.googlecode.com/svn/trunk@4430 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
8dcf114db9
commit
fd59d12000
@ -69,7 +69,9 @@ public:
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified c-string
|
||||
* (a null-terminated array of bytes).
|
||||
* (a null-terminated array of bytes). The returned SkData will have size()
|
||||
* equal to strlen(cstr) + 1. If cstr is NULL, it will be treated the same
|
||||
* as "".
|
||||
*/
|
||||
static SkData* NewWithCString(const char cstr[]);
|
||||
|
||||
|
@ -112,10 +112,13 @@ SkData* SkData::NewSubset(const SkData* src, size_t offset, size_t length) {
|
||||
}
|
||||
|
||||
SkData* SkData::NewWithCString(const char cstr[]) {
|
||||
if (NULL == cstr || 0 == cstr[0]) {
|
||||
return NewEmpty();
|
||||
size_t size;
|
||||
if (NULL == cstr) {
|
||||
cstr = "";
|
||||
size = 1;
|
||||
} else {
|
||||
return NewWithCopy(cstr, strlen(cstr));
|
||||
size = strlen(cstr) + 1;
|
||||
}
|
||||
return NewWithCopy(cstr, size);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user