Skip to content

Instantly share code, notes, and snippets.

@chrisa
Created August 12, 2012 09:40
Show Gist options
  • Select an option

  • Save chrisa/3330882 to your computer and use it in GitHub Desktop.

Select an option

Save chrisa/3330882 to your computer and use it in GitHub Desktop.
diff --git i/usdt.c w/usdt.c
index 7a25621..078f437 100644
--- i/usdt.c
+++ w/usdt.c
@@ -148,7 +148,7 @@ usdt_provider_enable(usdt_provider_t *provider)
return (-1);
}
- if ((usdt_strtab_add(&strtab, provider->name)) < 0) {
+ if ((usdt_strtab_add(&strtab, provider->name)) == 0) {
usdt_error(provider, USDT_ERROR_MALLOC);
return (-1);
}
diff --git i/usdt_dof.c w/usdt_dof.c
index a844533..1cd6bb0 100644
--- i/usdt_dof.c
+++ w/usdt_dof.c
@@ -112,11 +112,11 @@ usdt_strtab_add(usdt_strtab_t *strtab, const char *string)
strtab->strindex += (length + 1);
if ((strtab->data = realloc(strtab->data, strtab->strindex)) == NULL)
- return (-1);
+ return (0); /* note error return; new string index is never 0 */
memcpy((char *) (strtab->data + index), (char *)string, length + 1);
strtab->size = index + length + 1;
- return index;
+ return(index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment