예제 #1
0
static int
string_cmp(void *a, void *b)
{
    if (*(char *)a == '\0') {
	char **strp = _heim_get_isaextra(a, 1);

	if (*strp != NULL)
	    a = *strp; /* a is a string ref */
    }
    if (*(char *)b == '\0') {
	char **strp = _heim_get_isaextra(b, 1);

	if (*strp != NULL)
	    b = *strp; /* b is a string ref */
    }
    return strcmp(a, b);
}
예제 #2
0
static void
string_dealloc(void *ptr)
{
    heim_string_t s = ptr;
    heim_string_free_f_t *deallocp;
    heim_string_free_f_t dealloc;

    if (*(const char *)ptr != '\0')
	return;

    /* Possible string ref */
    deallocp = _heim_get_isaextra(s, 0);
    dealloc = *deallocp;
    if (dealloc != NULL) {
	char **strp = _heim_get_isaextra(s, 1);
	dealloc(*strp);
    }
}
예제 #3
0
heim_string_t
heim_string_ref_create(const char *string, heim_string_free_f_t dealloc)
{
    heim_string_t s;
    heim_string_free_f_t *deallocp;

    s = _heim_alloc_object(&_heim_string_object, 1);
    if (s) {
	const char **strp;

	((char *)s)[0] = '\0';
	deallocp = _heim_get_isaextra(s, 0);
	*deallocp = dealloc;
	strp = _heim_get_isaextra(s, 1);
	*strp = string;
    }
    return s;
}
예제 #4
0
const char *
heim_string_get_utf8(heim_string_t string)
{
    if (*(const char *)string == '\0') {
	const char **strp;

	/* String ref */
	strp = _heim_get_isaextra(string, 1);
	if (*strp != NULL)
	    return *strp;
    }
    return (const char *)string;
}
예제 #5
0
파일: data.c 프로젝트: abartlet/heimdal
heim_data_t
heim_data_ref_create(const void *data, size_t length,
                     heim_data_free_f_t dealloc)
{
    heim_octet_string *os;
    heim_data_free_f_t *deallocp;

    os = _heim_alloc_object(&_heim_data_object, sizeof(*os) + length);
    if (os) {
        os->data = (void *)data;
        os->length = length;
        deallocp = _heim_get_isaextra(os, 0);
        *deallocp = dealloc;
    }
    return (heim_data_t)os;
}
예제 #6
0
파일: data.c 프로젝트: abartlet/heimdal
static void
data_dealloc(void *ptr)
{
    heim_data_t d = ptr;
    heim_octet_string *os = (heim_octet_string *)d;
    heim_data_free_f_t *deallocp;
    heim_data_free_f_t dealloc;

    if (os->data == NULL)
        return;

    /* Possible string ref */
    deallocp = _heim_get_isaextra(os, 0);
    dealloc = *deallocp;
    if (dealloc != NULL)
        dealloc(os->data);
}