コード例 #1
0
ファイル: events_slave_mode.c プロジェクト: jiangxilong/yari
void enqueueEventMessage(unsigned char* data,int dataLen)
{
    EventMessage** iter;
    EventMessage* elem=(EventMessage*)javacall_malloc(sizeof(EventMessage));
    elem->data      =javacall_malloc(dataLen);
    elem->dataLen   =dataLen;
    elem->next      =NULL;
    memcpy(elem->data, data, dataLen);

    for(iter=&head; *iter!=NULL; iter=&((*iter)->next) )
        ;
    *iter=elem;
}
コード例 #2
0
ファイル: events_slave_mode.c プロジェクト: jiangxilong/yari
int dequeueInterprocessMessage(char*** argv)
{
    int argc = 0;
    if (EVENT_QUEUE_ACQUIRE)
    {
        int lengthTotal = 1;
        char *src = events_shared->data;

        while(*src) {
            argc++;
            lengthTotal += strlen(src) + 1;
            src += strlen(src) + 1;
        }

        if (argc) {
            *argv = javacall_malloc(lengthTotal + argc * sizeof(char*));
            src = (char*) ((*argv) + argc);
            memcpy(src, events_shared->data, lengthTotal);
            argc = 0;
            while(*src) {
                (*argv)[argc++] = src;
                src += strlen(src) + 1;
            }
            events_shared->data[0] = 0;
            events_shared->data[1] = 0;
        }
        EVENT_QUEUE_RELEASE;
    }
    return argc;
}
コード例 #3
0
static javacall_image_filter_handle
        create(
            javacall_const_utf16_string source_type,
            javacall_const_utf16_string dest_type)
{
    javacall_amms_image_filter_cnv_s* pIFc;
    javacall_image_filter_handle result;

    int i;
    if (javautil_unicode_equals(source_type, JAVACALL_AMMS_MIME_RAW_RGBA8888)
                == JAVACALL_FALSE)
        return NULL;

    for (i = 0; i < SupportedOutputCnt; i++)
        if (javautil_unicode_equals(dest_type, SupportedOutput[i])
                            == JAVACALL_TRUE) {
            pIFc = javacall_malloc(sizeof(javacall_amms_image_filter_cnv_s));
            if (pIFc != NULL) {
                memset(pIFc, 0, sizeof(*pIFc));
                pIFc->quality = DEFAULT_QUALITY;
                result = (javacall_image_filter_handle)pIFc;
                result->destroy = &javacall_amms_if_simple_destroy;
                result->clone   = &javacall_amms_if_simple_clone;
                result->addtoMP = &javacall_amms_if_simple_add;
                result->process = convertorsPnt[i];
                if (i == 0) /// JPEG
                    result->pParamAPI = &paramAPI;
                result->sifSize = sizeof(javacall_amms_image_filter_cnv_s);
                return result;
            } else break; /// Out of memory
        }

    return NULL;
}
コード例 #4
0
/**
 * Returns a new string that is a substring of this string. The
 * substring begins at the specified <code>beginIndex</code> and
 * extends to the character at index <code>endIndex - 1</code>.
 * Thus the length of the substring is <code>endIndex-beginIndex</code>.
 *
 * @param src input string
 * @param begin the beginning index, inclusive.
 * @param end the ending index, exclusive.
 * @param dest the output string, will contain the specified substring
 * @return <code>JAVACALL_OK</code> on success,
 *         <code>JAVACALL_FAIL</code> or any other negative value otherwise.
 */
javacall_result javautil_string_substring(char* src, int begin, int end,
                                          /*OUT*/ char** dest) {

    char* result = NULL;
    int srcLen = strlen(src);
    int destLen;

    *dest = NULL;

    if ((src == NULL) || (srcLen < 0) || (begin < 0) ||
        (end > srcLen) || (begin >= end)) {
        return JAVACALL_FAIL;
    }

    if (srcLen == 0) {
        *dest = '\0';
        return JAVACALL_OK;
    }

    destLen = end - begin;
    // SHOULD USE pcsl_mem_malloc() ?
    result = (char*)javacall_malloc((destLen+1)*sizeof(char));
    if (result == NULL) {
        return JAVACALL_OUT_OF_MEMORY;
    }

    memcpy(result, src+begin, destLen);
    result[destLen] = '\0';
    *dest = result;

    return JAVACALL_OK;
}
コード例 #5
0
ファイル: eventqueue.c プロジェクト: Sektor/phoneme-qtopia
/**
 * Creates the event queue lock.
 *
 * @return <tt>JAVACALL_OK</tt> if successully created lock
 *         <tt>JAVACALL_FAIL</tt> or negative value otherwise
 */
javacall_result javacall_create_event_queue_lock(void){
    /*
     * The Master mode needs a lock since all events put in asynchronously.
     * But slave mode may not if events can be put in the system GUI event
     * system.
     */
    HANDLE *mutex;

    specialId = TlsAlloc();
    if (TLS_OUT_OF_INDEXES == specialId) {
        return JAVACALL_FAIL;
    }

    mutex = javacall_malloc(sizeof(HANDLE));
    if (NULL == mutex) {
        return JAVACALL_FAIL;
    }

    if (0 == TlsSetValue(specialId, mutex)) {
        return JAVACALL_FAIL;
    }

    *mutex = CreateMutex(0, JAVACALL_FALSE, "eventQueueMutex");
    if (NULL == *mutex) {
        return JAVACALL_FAIL;
    }

    return JAVACALL_OK;
}
コード例 #6
0
javacall_utf16_string javautil_wcsdup(javacall_const_utf16_string src) {
    javacall_int32 length = 0;
    javacall_utf16_string result;
    if( src == NULL ) {
        return NULL;
    }
    if (JAVACALL_OK != javautil_unicode_utf16_ulength (src, &length)) {
        length = 0;
    }
    result = javacall_malloc(((unsigned int)length + 1) * sizeof(javacall_utf16));
    memcpy(result, src, ((unsigned int)length + 1) * sizeof(javacall_utf16));
    return result;
}
コード例 #7
0
javacall_media_processor_handle 
    javacall_media_processor_create(javacall_int64  media_processor_id)
{
    javacall_amms_media_processor_s* pMP = 
            javacall_malloc(sizeof(javacall_amms_media_processor_s));

    InitializeCriticalSection(&pMP->csHandle);
    pMP->filtersCnt = 0;
    pMP->media_processor_id = media_processor_id;
    pMP->inputData = NULL;
    pMP->outputData = NULL;
    pMP->hMPThread = NULL;
    pMP->bStartIsContinue = JAVACALL_FALSE;
    return pMP;
}
コード例 #8
0
/**
 * Duplicates a string
 * 
 * @param s input string
 * @return a newly allocated string with the same content as s
 */
char* javautil_string_duplicate(char *s) {
    int len;
    char *new_s;

    if (NULL == s){    
        return NULL;
    }
        
    len = strlen(s);
    new_s = (char*)javacall_malloc(len+1);
    if (NULL==new_s){
        return NULL;
    }

    strcpy(new_s, s);
    return new_s;
}
コード例 #9
0
static javacall_image_filter_handle clone(javacall_image_filter_handle filter_handle)
{
    javacall_image_filter_handle result;
    javacall_amms_image_filter_overlay_s* pIFo;
    if (filter_handle == NULL)
        return NULL;

    result = (javacall_image_filter_handle)
        javacall_malloc(filter_handle->sifSize);
    if (result)
        memcpy(result, filter_handle, filter_handle->sifSize);

    pIFo = (javacall_amms_image_filter_overlay_s*)result;
    pIFo->pPict = (javacall_amms_frame_RGB32*)
        javacall_amms_addref_frame(&pIFo->pPict->raw);
    return result;
}
コード例 #10
0
    /**
     * Initialize LCD API
     * Will be called once the Java platform is launched
     *
     * @return <tt>1</tt> on success, <tt>0</tt> on failure
     */
    javacall_result javacall_lcd_init(void) {
        if (VRAM.hdc == NULL) {
            VRAM.hdc =
                (javacall_pixel*)javacall_malloc(MAIN_WINDOW_CHILD_AREA_WIDTH *
                                                 MAIN_WINDOW_CHILD_AREA_HEIGHT *
                                                 sizeof(javacall_pixel));
            if (VRAM.hdc == NULL) {
                wprintf(
                    _T("ERROR: javacall_lcd_init(): VRAM allocation failed!\n"));
                return JAVACALL_FAIL;
            }

            VRAM.width  = MAIN_WINDOW_CHILD_AREA_WIDTH;
            VRAM.height = MAIN_WINDOW_CHILD_AREA_HEIGHT;
        }

        return JAVACALL_OK;
    }
コード例 #11
0
/**
 * Returns a new string that is a concatenation of two input strings.
 * Memory allocated within this function by javacall_malloc() and should be freed
 * by javacall_free()
 *
 * @param prefix the beginning/prefix string
 * @param suffix the ending/suffix string
 * @return concatenated string on success, NULL otherwise.
 */
char* javautil_string_strcat(const char* prefix, const char* suffix) {
    char *joined_string = NULL;
    int len1 = 0;
    int len2 = 0;

    if ((prefix == NULL) || (suffix == NULL)) {
        return NULL;
    }

    len1 = strlen(prefix);
    len2 = strlen(suffix);

    joined_string = (char*)javacall_malloc((len1+len2+1));
    if (joined_string == NULL) {
        return NULL;
    }
    

    memcpy(joined_string, prefix, len1);
    memcpy(joined_string+len1, suffix, len2);
    joined_string[len1+len2] = '\0';

    return joined_string;
}