Browse code

Fix map API.

Török Edvin authored on 2010/05/14 02:37:06
Showing 2 changed files
... ...
@@ -542,7 +542,7 @@ int32_t cli_bcapi_hashset_contains(struct cli_bc_ctx *ctx , int32_t id, uint32_t
542 542
 {
543 543
     struct cli_hashset *s = get_hashset(ctx, id);
544 544
     if (!s)
545
-	return 0;
545
+	return -1;
546 546
     return cli_hashset_contains(s, key);
547 547
 }
548 548
 
... ...
@@ -1060,7 +1060,7 @@ int32_t cli_bcapi_map_new(struct cli_bc_ctx *ctx, int32_t keysize, int32_t value
1060 1060
 {
1061 1061
     unsigned n = ctx->nmaps+1;
1062 1062
     struct cli_map *s = cli_realloc(ctx->maps, sizeof(*ctx->maps)*n);
1063
-    if (!s)
1063
+    if (!s || !keysize)
1064 1064
 	return -1;
1065 1065
     ctx->maps = s;
1066 1066
     ctx->nmaps = n;
... ...
@@ -707,7 +707,7 @@ void* cli_map_getvalue(struct cli_map *m)
707 707
 	return NULL;
708 708
     if (m->valuesize)
709 709
 	return (char*)m->u.sized_values + m->last_find*m->valuesize;
710
-    return &m->u.unsized_values[m->valuesize];
710
+    return m->u.unsized_values[m->last_find].value;
711 711
 }
712 712
 
713 713
 void cli_map_delete(struct cli_map *m)