1 /* 2 * Copyright 2006 The Android Open Source Project 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "SkEvent.h" 9 #include "SkMalloc.h" 10 initialize(const char * type)11void SkEvent::initialize(const char* type) { 12 fType = nullptr; 13 setType(type); 14 f32 = 0; 15 } 16 SkEvent()17SkEvent::SkEvent() { 18 initialize(""); 19 } 20 SkEvent(const SkEvent & src)21SkEvent::SkEvent(const SkEvent& src) { 22 *this = src; 23 setType(src.fType); 24 } 25 SkEvent(const char type[])26SkEvent::SkEvent(const char type[]) { 27 SkASSERT(type); 28 initialize(type); 29 } 30 ~SkEvent()31SkEvent::~SkEvent() { 32 sk_free(fType); 33 } 34 isType(const char type[]) const35bool SkEvent::isType(const char type[]) const { 36 size_t typeLen = strlen(type); 37 return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0; 38 } 39 setType(const char type[])40void SkEvent::setType(const char type[]) { 41 size_t typeLen = strlen(type); 42 fType = (char*) sk_malloc_throw(typeLen + 1); 43 memcpy(fType, type, typeLen); 44 fType[typeLen] = 0; 45 } 46