Esempio n. 1
0
/**
 * Delete the given CBS message. The memory used by the message will be
 * released to the memory pool.
 *
 * @param message The message that will have its memory freed.
 */
void jsr120_cbs_delete_msg(CbsMessage* msg) {

    if (msg != NULL) {
        pcsl_mem_free(msg->msgBuffer);
        pcsl_mem_free(msg);
    }
}
Esempio n. 2
0
/**
 * Free all of the memory used by a stored invocation.
 * 
 * @param stored pointer to an StoredInvoc.
 */
static void invocFree(StoredInvoc* invoc) {
    /*
     * An error occurred allocating memory; release all of the unused
     * Strings, free the structure and throw OutOfMemoryError.
     */
    if (invoc != NULL) {
        if (invoc->args != NULL) {
            /* Free the argument array and strings, if any */
            pcsl_string* args = invoc->args;
            int i = invoc->argsLen;
            while (i--) {
                pcsl_string_free(args++);
            }
            pcsl_mem_free(invoc->args);
        }

        if (invoc->data != NULL) {
            pcsl_mem_free(invoc->data);
        }

        pcsl_string_free(&invoc->url);
        pcsl_string_free(&invoc->type);
        pcsl_string_free(&invoc->action);
        pcsl_string_free(&invoc->ID);
        pcsl_string_free(&invoc->classname);
        pcsl_string_free(&invoc->invokingAuthority);
        pcsl_string_free(&invoc->invokingAppName);
        pcsl_string_free(&invoc->invokingClassname);
        pcsl_string_free(&invoc->invokingID);
        pcsl_string_free(&invoc->username);
        pcsl_string_free(&invoc->password);

        pcsl_mem_free(invoc);
    }
}
/**
 * Delete the given SMS message. The memory used by the message will be
 * released to the memory pool.
 *
 * @param message The message that will have its memory freed.
 */
void jsr120_sms_delete_msg(SmsMessage* sms) {
    if (sms) {
        pcsl_mem_free(sms->msgAddr);
        pcsl_mem_free(sms->msgBuffer);
        pcsl_mem_free(sms);
    }
}
Esempio n. 4
0
/**
 * Delete the given CBS message. The memory used by the message will be
 * released to the memory pool.
 *
 * @param message The message that will have its memory freed.
 */
void jsr120_cbs_delete_msg(CbsMessage* message) {

    if (message != NULL) {
        pcsl_mem_free(message->msgBuffer);
        pcsl_mem_free(message);
    }
}
Esempio n. 5
0
/**
 * Delete the given MMS message and release the memory used by the message to
 * the memory pool.
 *
 * @param msg The message that will have its memory freed.
 */
void jsr205_mms_delete_msg(MmsMessage* msg) {

    if (msg != NULL) {
        pcsl_mem_free(msg->fromAddress);
        pcsl_mem_free(msg->appID);
        pcsl_mem_free(msg->replyToAppID);
        pcsl_mem_free(msg->msgBuffer);
        pcsl_mem_free(msg);
    }
}
Esempio n. 6
0
void
JPEG_To_RGB_free(void *info)
{
    struct jpeg_decompress_struct *cinfo =
	(struct jpeg_decompress_struct *) info;
    jm_jpeg_destroy_decompress(cinfo);
    pcsl_mem_free(((jmf_src_data*)cinfo->client_data)->jerr);
    pcsl_mem_free(cinfo->client_data);
    pcsl_mem_free(cinfo->src);
    pcsl_mem_free(cinfo);
}
Esempio n. 7
0
void bt_push_shutdown()
{
    bt_push_t *push = g_registry;
    REPORT_INFO(LC_PUSH, "Shutting down Bluetooth PushRegistry.");
    while (push != NULL) {
        bt_push_t *next = push->next;
        javacall_bt_sddb_remove_record(push->record.id);
        pcsl_mem_free(push->record.data);
        close_all(push);
        pcsl_mem_free(push);
        push = next;
    }
    g_registry = NULL;
    javacall_bt_sddb_finalize();
}
Esempio n. 8
0
/**
 * Perform a platform-defined procedure for obtaining random bytes and
 * store the obtained bytes into b, starting from index 0.
 * (see IETF RFC 1750, Randomness Recommendations for Security,
 *  http://www.ietf.org/rfc/rfc1750.txt)
 * @param b array that receives random bytes
 * @param nbytes the number of random bytes to receive, must not be less than size of b
 * @return the number of actually obtained random bytes, -1 in case of an error
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
KNIDECL(com_sun_midp_crypto_PRand_getRandomBytes) {
    jint size;
    jboolean res = KNI_FALSE;
    unsigned char* buffer;

    KNI_StartHandles(1);
    KNI_DeclareHandle(hBytes);
    KNI_GetParameterAsObject(1, hBytes);

    size = KNI_GetParameterAsInt(2);

    buffer = pcsl_mem_malloc(size);
    if (0 == buffer) {
        KNI_ThrowNew(midpOutOfMemoryError, NULL);
    } else {
        int i;
        res = get_random_bytes_port(buffer, size);
        for(i=0; i<size; i++) {
            KNI_SetByteArrayElement(hBytes,i,(jbyte)buffer[i]);
        }
        pcsl_mem_free(buffer);
    }
    
    KNI_EndHandles();
    KNI_ReturnBoolean(res);
}
Esempio n. 9
0
/**
 * Unregisters the given listener of the specified type.
 *
 * @param fn_callback pointer to the listener function
 * @param listenerType type of events this listener listens for
 *
 * @return error code: ALL_OK if successful,
 *                     NOT_FOUND if the listener was not found
 */
MIDPError
remove_event_listener_impl(void* fn_callback, int listenerType) {
    GenericListener *pListener, *pPrev = NULL;
    int index;

    index = get_listeners_list_index(listenerType);
    if (index < 0) {
        return NOT_FOUND;
    }

    pListener = g_pRegisteredListeners[index];

    while (pListener) {
        if (pListener->fn_callback == fn_callback) {
            if (pPrev) {
                pPrev->pNext = pListener->pNext;
            } else {
                g_pRegisteredListeners[index] = pListener->pNext;
                if (g_pRegisteredListeners[index] == NULL) {
                    remove_listener_type(listenerType);
                }
            }

            pcsl_mem_free(pListener);

            return ALL_OK;
        }

        pPrev = pListener;
        pListener = pListener->pNext;
    }

    return NOT_FOUND;
}
Esempio n. 10
0
javacall_result bt_push_unregister_url(const char *url)
{
    bt_port_t port;
    bt_push_t *push, *prev;
    REPORT_INFO(LC_PUSH, "Bluetooth PushRegistry URL un-registration:");
    REPORT_INFO1(LC_PUSH, "%s", url);
    bt_push_parse_url(url, &port, NULL);
    push = find_push(&port, &prev);
    if (push == NULL) {
        return JAVACALL_FAIL;
    }
    /* remove the service record */
    javacall_bt_sddb_remove_record(push->record.id);
    /* close server and client connections */
    close_all(push);
    /* remove the entry */
    if (prev != NULL) {
        prev->next = push->next;
    } else {
        g_registry = push->next;
    }
    g_count--;
    pcsl_mem_free(push);
    push_save();
    javacall_bt_stack_set_service_classes(javacall_bt_sddb_get_service_classes(0));
    REPORT_INFO(LC_PUSH, "Un-registration successful.");
    return JAVACALL_OK;
}
Esempio n. 11
0
/*
 * Test the pcsl_mem_malloc method and pcsl_mem_get_free_heap method
 * This test ensures that after a pcsl_mem_malloc call for 1000 bytes
 * that the heap size available is reduced by 1000 bytes.
 * note: acutally, the heap pcsl_memory.c impl adds 4 guard bytes, so
 * we have to take that into account...
 */
void testMalloc() {
    int spcBefore;
    int spcAfter;
    void * buffer;

    spcBefore = pcsl_mem_get_free_heap();

    buffer = pcsl_mem_malloc(1000);
    assertTrue("failed to allocate a 1000 byte buffer", 
	       (buffer != NULL));

    spcAfter = pcsl_mem_get_free_heap();

    if (spcAfter != -1) {
        assertTrue("pcsl_mem_malloc & heap_size_available mis-match",
		   (spcBefore - 1004 == spcAfter ||
		    spcBefore - 1000 == spcAfter));
    }

    spcBefore = pcsl_mem_get_free_heap();

    pcsl_mem_free(buffer);

    spcAfter = pcsl_mem_get_free_heap();

    if (spcAfter != -1) {
        assertTrue("pcsl_mem_free & heap_size_available mis-match",
		   (spcBefore + 1004 == spcAfter ||
		    spcBefore + 1000 == spcAfter));
    }
}
Esempio n. 12
0
/**
 * Test address to string conversion.
 */
void
testAddrToString() {
    unsigned char addr[4];
    unsigned short* result;
    int resultLen;
    int status;
    int i;

    /* test of success */
    addr[0] = 80;
    addr[1] = 80;
    addr[2] = 80;
    addr[3] = 80;

    status = pcsl_network_addrToString(addr, &result, &resultLen);
    assertTrue("gethostbyname failed", PCSL_NET_SUCCESS == status);
    if (PCSL_NET_SUCCESS != status) {
        return;
    }

    printf("Result of addr \"80.80.80.80\" = ");
    for (i = 0; i < resultLen, i++) {
        putchar(result[i]);
    }

    putchar('\n');

    pcsl_mem_free(result);
}
Esempio n. 13
0
/**
 * Cleans up resources used by file system. It is only needed for the 
 * Ram File System (RMFS).
 * @return 0 on success, -1 otherwise
 */
int pcsl_file_finalize() {
#ifndef PCSL_RAMFS_USE_STATIC
    if (RamfsMemory != NULL) {
        pcsl_mem_free(RamfsMemory);
    }
#endif /* ! PCSL_RAMSF_USE_STATIC */
    return 0;
}
Esempio n. 14
0
/*
 * Test simple memory allocation 
 * This test checks to see that NULL is not returned from a pcsl_mem_malloc
 * call.  (Note:  NULL may be a valid return in a very full/limited
 * memory system)
 */
void testAllocation() {
    void * buffer = pcsl_mem_malloc(1000);

    assertTrue("failed to allocate a 1000 byte buffer", 
	       (buffer != NULL));

    pcsl_mem_free(buffer);
}
Esempio n. 15
0
/**
 * Release all memory used by an MMS header.
 *
 * @param header The MMS header whose memory will be freed.
 */
void destroyMMSHeader(MmsHeader* header) {

    if (header != NULL) {
        /* Use pcsl_mem_free(header->part) to free each part. */

        /* Free the header itself. */
        pcsl_mem_free(header);
    }
}
/**
 * Frees the memory occupied by the given MidletSuiteData structure.
 *
 * @param pData MidletSuiteData entry to be freed
 */
void
free_suite_data_entry(MidletSuiteData* pData) {
    if (pData != NULL) {
        if ((pData->jarHashLen > 0) && pData->varSuiteData.pJarHash) {
            pcsl_mem_free(pData->varSuiteData.pJarHash);
        }

        pcsl_string_free(&pData->varSuiteData.midletClassName);
        pcsl_string_free(&pData->varSuiteData.displayName);
        pcsl_string_free(&pData->varSuiteData.iconName);
        pcsl_string_free(&pData->varSuiteData.suiteVendor);
        pcsl_string_free(&pData->varSuiteData.suiteName);
        pcsl_string_free(&pData->varSuiteData.pathToJar);
        pcsl_string_free(&pData->varSuiteData.pathToSettings);

        pcsl_mem_free(pData);
    }
}
/**
 * Reads the given file into the given buffer.
 * File contents is read as one piece.
 *
 * @param ppszError pointer to character string pointer to accept an error
 * @param pFileName file to read
 * @param outBuffer buffer where the file contents should be stored
 * @param outBufferLen length of the outBuffer
 *
 * @return status code (ALL_OK if there was no errors)
 */
MIDPError
read_file(char** ppszError, const pcsl_string* pFileName,
          char** outBuffer, long* outBufferLen) {
    int handle, status = ALL_OK;
    long fileSize, len;
    char* pszTemp;
    char* buffer = NULL;

    *ppszError  = NULL;
    *outBuffer  = NULL;
    *outBufferLen = 0;

    /* open the file */
    handle = storage_open(ppszError, pFileName, OPEN_READ);
    if (*ppszError != NULL) {
        if (!storage_file_exists(pFileName)) {
            return NOT_FOUND;
        }
        return IO_ERROR;
    }

    do {
        /* get the size of file */
        fileSize = storageSizeOf(ppszError, handle);
        if (*ppszError != NULL) {
            status = IO_ERROR;
            break;
        }

        if (fileSize > 0) {
            /* allocate a buffer to store the file contents */
            buffer = (char*)pcsl_mem_malloc(fileSize);
            if (buffer == NULL) {
                status = OUT_OF_MEMORY;
                break;
            }

            /* read the whole file */
            len = storageRead(ppszError, handle, buffer, fileSize);
            if (*ppszError != NULL || len != fileSize) {
                pcsl_mem_free(buffer);
                status = IO_ERROR;
            }
        }
    } while (0);

    /* close the file */
    storageClose(&pszTemp, handle);
    storageFreeError(pszTemp);

    if (status == ALL_OK) {
        *outBuffer    = buffer;
        *outBufferLen = fileSize;
    }

    return (MIDPError)status;
}
Esempio n. 18
0
/**
 * Deconstruct the entire list and free all memory.
 *
 * @param head The first element of the list to be deconstructed.
 */
void jsr120_list_destroy(ListElement* head) {

    /* If the list doesn't exist, exit now. */
    if (head == NULL) {
        return;
    }

    /* If the next element exists, recursively destroy. */
    if (head->next) {
        jsr120_list_destroy(head->next);
    }

    /* Release any string ID memory. */
    pcsl_mem_free(head->strid);

    /* Release the memory required by the list element. */
    pcsl_mem_free(head);
}
Esempio n. 19
0
javacall_bool bt_push_accept(bt_pushid_t pushid, const char *filter,
        javacall_handle *handle)
{
    bt_push_t *push = (bt_push_t *)pushid;
    bt_client_t *client;
    if (push == NULL) {
        return JAVACALL_FALSE;
    }
    client = (bt_client_t *)pcsl_mem_malloc(sizeof(bt_client_t));
    switch (push->port.protocol) {
        case BT_L2CAP:
            if (javacall_bt_l2cap_accept(push->server,
                    &client->handle, &client->bdaddr,
                    &client->rmtu, &client->tmtu) != JAVACALL_OK) {
                pcsl_mem_free(client);
                return JAVACALL_FALSE;
            }
            break;
        case BT_SPP:
        case BT_GOEP:
            if (javacall_bt_rfcomm_accept(push->server,
                    &client->handle, &client->bdaddr) != JAVACALL_OK) {
                pcsl_mem_free(client);
                return JAVACALL_FALSE;
            }
            break;
        default:
            pcsl_mem_free(client);
            return JAVACALL_FALSE;
    }
    if (bt_push_test_filter(client->bdaddr, filter) == JAVACALL_TRUE) {
        bt_client_t **client_ptr = &push->client;
        while (*client_ptr != NULL) {
            client_ptr = &(*client_ptr)->next;
        }
        *client_ptr = client;
        client->next = NULL;
        *handle = client->handle;
        return JAVACALL_TRUE;
    }
    close_handle(push->port.protocol, client->handle);
    pcsl_mem_free(client);
    return JAVACALL_FALSE;
}
Esempio n. 20
0
/**
 * Transforms prepared result buffer to jstring object and release memory of 
 * the allocated buffer.
 * It is safe to call this function after detecting out-of-memory error
 * provided that buf is set to _JSR211_RESULT_INITIALIZER_
 */
static void result2string(_JSR211_INTERNAL_RESULT_BUFFER_* buf, jstring str) {
    if (buf->len > 0 && buf->buf != NULL) {
        KNI_NewString(buf->buf, buf->len, str);
        pcsl_mem_free(buf->buf);
    } else {
        KNI_ReleaseHandle(str);
    }
    buf->len = 0;
    buf->buf = NULL;
}
/**
 * Reads named secure resource of the suite with specified suiteId
 * from secure persistent storage.
 *
 * Note that when porting memory for the in/out parameter
 * returnValue MUST be allocated using pcsl_mem_malloc().
 * The caller is responsible for freeing it.
 *
 * @param suiteId           The suite id used to identify the MIDlet suite
 * @param resourceName      The name of secure resource to read from storage
 * @param returnValue       The in/out parameter that will return the
 *                          value part of the requested secure resource
 *                          (NULL is a valid return value)
 * @param valueSize         The length of the secure resource value
 *
 * @return one of the error codes:
 * <pre>
 *     ALL_OK, OUT_OF_MEMORY, NOT_FOUND,
 *     SUITE_CORRUPTED_ERROR, BAD_PARAMS
 * </pre>
 */
MIDPError
midp_suite_read_secure_resource(SuiteIdType suiteId,
                                const pcsl_string* resourceName,
                                jbyte **returnValue,
                                jint *valueSize) {
    pcsl_string filename = PCSL_STRING_NULL;
    char *pszError = NULL;
    MIDPError errorCode;
    int bytesRead;
    int handle;

    *returnValue = NULL;
    *valueSize = 0;

    errorCode = get_secure_resource_file(suiteId, resourceName, &filename);
    if (errorCode != ALL_OK) {
        pcsl_string_free(&filename);
        return errorCode;
    }

    handle = storage_open(&pszError, &filename, OPEN_READ);
    pcsl_string_free(&filename);
    if (pszError != NULL) {
        storageFreeError(pszError);
        return SUITE_CORRUPTED_ERROR;
    }

    do {
        bytesRead = storageRead(&pszError, handle,
            (char*)valueSize, sizeof (int));
        if (bytesRead != sizeof (int) || *valueSize == 0)
            break;

        *returnValue = (jbyte*)pcsl_mem_malloc(*valueSize * sizeof (jbyte));
        if (*returnValue == NULL) {
            errorCode = OUT_OF_MEMORY;
            break;
        }

        bytesRead = storageRead(&pszError, handle, (char*)(*returnValue),
            *valueSize * sizeof (jbyte));

        if (pszError != NULL || bytesRead != *valueSize) {
            errorCode = SUITE_CORRUPTED_ERROR;
            pcsl_mem_free(*returnValue);
            *returnValue = NULL;
            break;
        }
    } while (0);

    storageClose(&pszError, handle);
    storageFreeError(pszError);

    return errorCode;
}
Esempio n. 22
0
/**
 * Shutdowns Links subsystem.
 */
void midp_links_shutdown() {
    if (portals != NULL) {
        int i;
        for (i = 0; i < JVM_MaxIsolates(); i++) {
            portal_free(&portals[i]);       
        }

        pcsl_mem_free(portals);        
        portals = NULL;
    }
}
Esempio n. 23
0
static void close_all(bt_push_t *push)
{
    bt_client_t *client = push->client;
    close_handle(push->port.protocol, push->server);
    while (client != NULL) {
        bt_client_t *next = client->next;
        close_handle(push->port.protocol, client->handle);
        pcsl_mem_free(client);
        client = next;
    }
    push->client = NULL;
}
Esempio n. 24
0
/**
 * @internal
 *
 * FUNCTION:      pcsl_end_memory()
 * TYPE:          private operation
 * OVERVIEW:      Finalize the PCSL memory pool
 * INTERFACE:
 *   parameters:  count   address to store memory leak count
 *                size    address to store totol bytes of memory leaked
 *   returns:     the number of memory leaks detected
 *                
 */
static int
pcsl_end_memory(int* count, int* size) {
    _PcslMemHdrPtr pcslMemoryHdr;
    char*          pcslMemoryPtr;

    *count = 0;
    *size  = 0;

    for (pcslMemoryPtr = PcslMemoryStart; 
         pcslMemoryPtr < PcslMemoryEnd;
         pcslMemoryPtr += pcslMemoryHdr->size + sizeof(_PcslMemHdr)) {

        pcslMemoryHdr = (_PcslMemHdrPtr)pcslMemoryPtr;

        if (pcslMemoryHdr->magic != MAGIC) {
            REPORT1("ERROR: Corrupted start of memory header: 0x%p\n", 
                    pcslMemoryPtr);
            return -1;
        }
#ifdef PCSL_DEBUG
        if (pcslMemoryHdr->guard != GUARD_WORD) {
            report("ERROR: Corrupted end of memory header: 0x%p\n",
                   pcslMemoryPtr);
            return -1;
        }

        /* The memory block header is valid, now check the guard data */
        if (verify_tail_guard_data(pcslMemoryHdr)) {
            report("ERROR: Memory overrun: 0x%p\n",
                   pcslMemoryPtr);
            print_alloc("allocated", 
                        pcslMemoryHdr->filename, 
                        pcslMemoryHdr->lineno);
        }
#endif 

        if (pcslMemoryHdr->free != 1) {

#ifdef PCSL_DEBUG
            report("WARNING: memory leak: size= %d  address= 0x%p\n",
                   pcslMemoryHdr->size,
                   (void*)((char*)pcslMemoryHdr + sizeof(_PcslMemHdr)));
            print_alloc("allocated", 
                        pcslMemoryHdr->filename, pcslMemoryHdr->lineno);
#endif
            pcsl_mem_free((void*)((char*)pcslMemoryHdr + sizeof(_PcslMemHdr)));
            *count += 1;
            *size  += pcslMemoryHdr->size;
        }
    }
    return *count;
}
Esempio n. 25
0
/**
 * The close function  loses the file with descriptor identifier in FS. 
 */
int pcsl_file_close(void *handle) 
{
    if (NULL == handle)
        return -1;

    {
        PCSLFile* pFH = (PCSLFile*)handle;
        pcsl_file_commitwrite(handle); /* commit pending writes */
        if (!CloseHandle(pFH->fileHandle))
            return -1;
        pcsl_mem_free(handle);
        return 0;
    }
}
Esempio n. 26
0
javacall_result bt_push_register_url(const char *url, const void *data,
        size_t size)
{
    bt_port_t port;
    bt_params_t params;
    bt_push_t *push;
    REPORT_INFO(LC_PUSH, "Bluetooth PushRegistry URL registration:");
    REPORT_INFO1(LC_PUSH, "%s", url);
    bt_push_parse_url(url, &port, &params);
    push = find_push(&port, NULL);
    if (push != NULL) {
        /* found existing entry with the same protocol/uuid, can not proceed */
        REPORT_ERROR(LC_PUSH, "Entry already exists, registration failed.");
        return JAVACALL_FAIL;
    }
    /* save the entry in the registry */
    push = (bt_push_t *)pcsl_mem_malloc(sizeof(bt_push_t));
    if (push == NULL) {
        REPORT_ERROR(LC_PUSH, "Failed to allocate memory.");
        return JAVACALL_FAIL;
    }
    memcpy(&push->port, &port, sizeof(bt_port_t));
    memcpy(&push->params, &params, sizeof(bt_params_t));
    push->record.id = BT_INVALID_SDDB_HANDLE;
    push->record.classes = 0;
    if (data != NULL) {
        push->record.data = pcsl_mem_malloc(size);
        if (push->record.data == NULL) {
            pcsl_mem_free(push);
            return JAVACALL_FAIL;
        }
        memcpy(push->record.data, data, size);
    } else {
        push->record.data = NULL;
    }
    push->record.size = size;
    push->server = BT_INVALID_HANDLE;
    push->client = NULL;
    push->next = g_registry;
    g_registry = push;
    g_count++;
    if (javacall_bt_sddb_update_record(&push->record.id, push->record.classes,
            push->record.data, push->record.size) != JAVACALL_OK) {
        return JAVACALL_FAIL;
    }
    push_save();
    REPORT_INFO(LC_PUSH, "Registration successful.");
    return JAVACALL_OK;
}
Esempio n. 27
0
static void
rp_decref(rendezvous *rp)
{
    rp->refcount -= 1;
    if (rp->refcount == 0) {
        if (rp->msg != INVALID_REFERENCE_ID) {
            /* IMPL_NOTE: really should be an assertion failure */
            KNI_FatalError("rp_decref refcount 0 with stale refid!");
        }
#if ENABLE_I3_TEST
        log_rp_free(rp);
#endif
        pcsl_mem_free(rp);
    }
}
Esempio n. 28
0
/**
 * Remove the entry by updating the pointers in the next and 
 * previous entries.
 * The pointers in the entry are set to NULL to prevent accidental
 * dereferences.
 */
static void removeEntry(StoredLink* entry) {
    if (entry != NULL) {
        StoredLink *blink = entry->blink;
        StoredLink *flink = entry->flink;

        if (blink == NULL) {
            invocQueue = flink;
        } else {
            blink->flink = flink;
        }
        if (flink != NULL) {
            flink->blink = blink;
        }
        pcsl_mem_free(entry);
    }
}
Esempio n. 29
0
javacall_result bt_push_reject(bt_pushid_t pushid)
{
    bt_push_t *push = (bt_push_t *)pushid;
    bt_client_t *client;
    if (push == NULL) {
        return JAVACALL_FAIL;
    }
    client = push->client;
    while (client != NULL) {
        bt_client_t *next = client->next;
        close_handle(push->port.protocol, client->handle);
        pcsl_mem_free(client);
        client = next;
    }
    push->client = NULL;
    return JAVACALL_OK;
}
Esempio n. 30
0
/*
 * Test the fact that global heap size never changes
 */
void testHeapSize() {
     void *buffer;
     int rv, rv2, rv3;

     rv = pcsl_mem_get_total_heap();
   
     buffer = pcsl_mem_malloc(1000);

     rv2 = pcsl_mem_get_total_heap();

     pcsl_mem_free(buffer);

     rv3 = pcsl_mem_get_total_heap();

     assertTrue("pcsl total heap size should never change, but did",
	        (rv == rv2) && (rv2 == rv3));
}