diff options
author | Michal Hruby <michal.mhr@gmail.com> | 2010-06-02 16:45:17 +0200 |
---|---|---|
committer | Michal Hruby <michal.mhr@gmail.com> | 2010-06-02 16:45:17 +0200 |
commit | 9e8401cac803ca83cf24272fc74b661d2c94dde3 (patch) | |
tree | 7d0ca1a67410c7df36907bfeb6740742f5313dde /npapi-plugin | |
parent | bdb8ece38901056ef1d01db50b78d76a44397a62 (diff) |
NPAPI plugin: Fix small leak, remove a few debugs
Diffstat (limited to 'npapi-plugin')
-rw-r--r-- | npapi-plugin/np-zeitgeist.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/npapi-plugin/np-zeitgeist.c b/npapi-plugin/np-zeitgeist.c index 0adee7e..de63dd7 100644 --- a/npapi-plugin/np-zeitgeist.c +++ b/npapi-plugin/np-zeitgeist.c @@ -46,9 +46,9 @@ static char *actor = NULL; static bool hasMethod(NPObject* obj, NPIdentifier methodName) { char *name; - g_debug("np-zeitgeist: %s", __func__); name = npnfuncs->utf8fromidentifier(methodName); + if (!strcmp(name, "insertEvent")) return true; else if (!strcmp(name, "setActor")) return true; @@ -75,7 +75,7 @@ invokeInsertEvent (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVa if (!NPVARIANT_IS_STRING (args[i])) { npnfuncs->setexception(obj, "string argument expected"); - g_debug ("argument #%d is not string", i); + g_debug ("argument #%d must be string", i); return false; } } @@ -129,7 +129,7 @@ invokeInsertEvent (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVa static bool invokeSetActor (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVariant *result) { - const NPString *actorName; + const char *actorName; if(argCount != 1 || !NPVARIANT_IS_STRING (args[0])) { @@ -137,11 +137,14 @@ invokeSetActor (NPObject *obj, const NPVariant *args, uint32_t argCount, NPVaria return false; } - actorName = &NPVARIANT_TO_STRING (args[0]); + actorName = NPVARIANT_TO_STRING (args[0]).UTF8Characters; + g_debug ("setting actor to: \"%s\"", actorName); - g_debug ("setting actor to: \"%s\"", - actorName->UTF8Characters); - actor = g_strdup(actorName->UTF8Characters); + if (actor) + { + g_free(actor); + } + actor = g_strdup (actorName); VOID_TO_NPVARIANT (*result); @@ -152,15 +155,12 @@ static bool invoke(NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result) { char *name; - g_debug("np-zeitgeist: %s", __func__); - name = npnfuncs->utf8fromidentifier(methodName); if(name) { if (!strcmp (name, "insertEvent")) { - g_debug("np-zeitgeist: invoke insertEvent"); return invokeInsertEvent(obj, args, argCount, result); } else if (!strcmp (name, "setActor")) @@ -177,8 +177,6 @@ static bool hasProperty(NPObject *obj, NPIdentifier propertyName) { char *name; - g_debug("np-zeitgeist: %s", __func__); - name = npnfuncs->utf8fromidentifier(propertyName); if (name) @@ -200,8 +198,6 @@ static bool getProperty(NPObject *obj, NPIdentifier propertyName, NPVariant *result) { char *name; - g_debug("np-zeitgeist: %s", __func__); - name = npnfuncs->utf8fromidentifier(propertyName); // FIXME: move all of this into separate Interpretation object? |