2005-03-14 23:57:21 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2007-01-21 17:24:29 +03:00
|
|
|
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
|
2005-03-14 23:57:21 +03:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-03-14 23:57:21 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "orte_config.h"
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "orte/constants.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "orte/class/orte_value_array.h"
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
|
|
|
|
static void orte_value_array_construct(orte_value_array_t* array)
|
|
|
|
{
|
|
|
|
array->array_items = NULL;
|
|
|
|
array->array_size = 0;
|
|
|
|
array->array_item_sizeof = 0;
|
|
|
|
array->array_alloc_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void orte_value_array_destruct(orte_value_array_t* array)
|
|
|
|
{
|
|
|
|
if (NULL != array->array_items)
|
|
|
|
free(array->array_items);
|
|
|
|
}
|
|
|
|
|
2007-01-21 17:24:29 +03:00
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
orte_value_array_t,
|
|
|
|
opal_object_t,
|
|
|
|
orte_value_array_construct,
|
|
|
|
orte_value_array_destruct
|
|
|
|
);
|
2005-03-14 23:57:21 +03:00
|
|
|
|
|
|
|
|
2006-08-15 23:54:10 +04:00
|
|
|
int orte_value_array_set_size(orte_value_array_t* array, orte_std_cntr_t size)
|
2005-03-14 23:57:21 +03:00
|
|
|
{
|
|
|
|
#if OMPI_ENABLE_DEBUG
|
|
|
|
if(array->array_item_sizeof == 0) {
|
2005-07-04 03:31:27 +04:00
|
|
|
opal_output(0, "orte_value_array_set_size: item size must be initialized");
|
2005-03-14 23:57:21 +03:00
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(size > array->array_alloc_size) {
|
|
|
|
while(array->array_alloc_size < size)
|
|
|
|
array->array_alloc_size <<= 1;
|
|
|
|
array->array_items = (unsigned char *)realloc(array->array_items,
|
|
|
|
array->array_alloc_size * array->array_item_sizeof);
|
|
|
|
if (NULL == array->array_items)
|
|
|
|
return ORTE_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
2005-05-01 04:58:06 +04:00
|
|
|
|
2005-03-14 23:57:21 +03:00
|
|
|
array->array_size = size;
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|
|
|
|
|