looks good

On Mon, 2009-10-12 at 08:06 +1300, angus salkeld wrote:
> Hi
> 
> This is so we can increment all integer types correctly.
> 
> Steve you wanted uint64_t stats counters and we will need this
> patch to achieve this.
> 
> -Angus
> 
> diff --git a/exec/objdb.c b/exec/objdb.c
> index 0e4d6e9..726b302 100644
> --- a/exec/objdb.c
> +++ b/exec/objdb.c
> @@ -968,9 +968,45 @@ static int object_key_increment (
>                       break;
>               }
>       }
> -     if (found && object_key->value_len == sizeof(int)) {
> -             (*(int *)object_key->value)++;
> -             *value = *(int *)object_key->value;
> +
> +     if (found) {
> +             switch (object_key->value_type) {
> +             case OBJDB_VALUETYPE_INT16:
> +                     (*(int16_t *)object_key->value)++;
> +                     break;
> +             case OBJDB_VALUETYPE_UINT16:
> +                     (*(uint16_t *)object_key->value)++;
> +                     break;
> +             case OBJDB_VALUETYPE_INT32:
> +                     (*(int32_t *)object_key->value)++;
> +                     break;
> +             case OBJDB_VALUETYPE_UINT32:
> +                     (*(uint32_t *)object_key->value)++;
> +                     break;
> +             case OBJDB_VALUETYPE_INT64:
> +                     (*(int64_t *)object_key->value)++;
> +                     break;
> +             case OBJDB_VALUETYPE_UINT64:
> +                     (*(uint64_t *)object_key->value)++;
> +                     break;
> +             case OBJDB_VALUETYPE_ANY:
> +                     /* for backwards compatibilty */
> +                     if (object_key->value_len == sizeof(int)) {
> +                             (*(int *)object_key->value)++;
> +                     }
> +                     else {
> +                             res = -1;
> +                     }
> +                     break;
> +             default:
> +                     res = -1;
> +                     break;
> +             }
> +             if (res == 0) {
> +                     /* nasty, not sure why we need to return this typed
> +                      * instead of void* */
> +                     *value = *(int *)object_key->value;
> +             }
>       }
>       else {
>               res = -1;
> @@ -1014,9 +1050,46 @@ static int object_key_decrement (
>                       break;
>               }
>       }
> -     if (found && object_key->value_len == sizeof(int)) {
> -             (*(int *)object_key->value)--;
> -             *value = *(int *)object_key->value;
> +
> +
> +     if (found) {
> +             switch (object_key->value_type) {
> +             case OBJDB_VALUETYPE_INT16:
> +                     (*(int16_t *)object_key->value)--;
> +                     break;
> +             case OBJDB_VALUETYPE_UINT16:
> +                     (*(uint16_t *)object_key->value)--;
> +                     break;
> +             case OBJDB_VALUETYPE_INT32:
> +                     (*(int32_t *)object_key->value)--;
> +                     break;
> +             case OBJDB_VALUETYPE_UINT32:
> +                     (*(uint32_t *)object_key->value)--;
> +                     break;
> +             case OBJDB_VALUETYPE_INT64:
> +                     (*(int64_t *)object_key->value)--;
> +                     break;
> +             case OBJDB_VALUETYPE_UINT64:
> +                     (*(uint64_t *)object_key->value)--;
> +                     break;
> +             case OBJDB_VALUETYPE_ANY:
> +                     /* for backwards compatibilty */
> +                     if (object_key->value_len == sizeof(int)) {
> +                             (*(int *)object_key->value)--;
> +                     }
> +                     else {
> +                             res = -1;
> +                     }
> +                     break;
> +             default:
> +                     res = -1;
> +                     break;
> +             }
> +             if (res == 0) {
> +                     /* nasty, not sure why we need to return this typed
> +                      * instead of void* */
> +                     *value = *(int *)object_key->value;
> +             }
>       }
>       else {
>               res = -1;
> 
> 
> _______________________________________________
> Openais mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/openais

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to