当前位置: 首页>>代码示例>>C++>>正文


C++ CATCH_BAD_ALLOC_RET函数代码示例

本文整理汇总了C++中CATCH_BAD_ALLOC_RET函数的典型用法代码示例。如果您正苦于以下问题:C++ CATCH_BAD_ALLOC_RET函数的具体用法?C++ CATCH_BAD_ALLOC_RET怎么用?C++ CATCH_BAD_ALLOC_RET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CATCH_BAD_ALLOC_RET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Java_sun_awt_windows_WPrintDialogPeer__1show

JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WPrintDialogPeer__1show(JNIEnv *env, jobject peer)
{
    TRY;

    DASSERT(peer != NULL);
    jobject target = env->GetObjectField(peer, AwtObject::targetID);
    DASSERT(target != NULL);
    jobject parent = env->GetObjectField(peer, AwtPrintDialog::parentID);
    DASSERT(parent != NULL);
    jobject control = env->GetObjectField(target, AwtPrintDialog::controlID);
    DASSERT(control != NULL);

    AwtComponent *awtParent = (AwtComponent *)JNI_GET_PDATA(parent);
    DASSERT(awtParent != NULL);
    
    PRINTDLG pd;
    memset(&pd, 0, sizeof(PRINTDLG));
    pd.lStructSize = sizeof(PRINTDLG);
    AwtPrintControl::InitPrintDialog(env, control, pd);
    pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDialogHookProc;
    pd.lpfnSetupHook = (LPSETUPHOOKPROC)PrintDialogHookProc;
    pd.Flags |= PD_ENABLESETUPHOOK | PD_ENABLEPRINTHOOK;    
    AwtDialog::ModalDisable(NULL);
    BOOL ret = AwtPrintDialog::PrintDlg(&pd);
    AwtDialog::ModalEnable(NULL);
    AwtDialog::ModalNextWindowToFront(awtParent->GetHWnd());
    if (ret) {
        AwtPrintControl::UpdateAttributes(env, control, pd);
    }

    return ret;

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:35,代码来源:awt_PrintDialog.cpp

示例2: DASSERT

/*
 * Class:     sun_awt_windows_WClipboard
 * Method:    getClipboardFormats
 * Signature: ()[J
 */
JNIEXPORT jlongArray JNICALL
Java_sun_awt_windows_WClipboard_getClipboardFormats
    (JNIEnv *env, jobject self)
{
    TRY;

    DASSERT(::GetOpenClipboardWindow() == AwtToolkit::GetInstance().GetHWnd());

    jsize nFormats = ::CountClipboardFormats();
    jlongArray formats = env->NewLongArray(nFormats);
    if (formats == NULL) {
        throw std::bad_alloc();
    }
    if (nFormats == 0) {
        return formats;
    }
    jboolean isCopy;
    jlong *lFormats = env->GetLongArrayElements(formats, &isCopy),
        *saveFormats = lFormats;
    UINT num = 0;

    for (jsize i = 0; i < nFormats; i++, lFormats++) {
        *lFormats = num = ::EnumClipboardFormats(num);
    }

    env->ReleaseLongArrayElements(formats, saveFormats, 0);

    return formats;

    CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:36,代码来源:awt_Clipboard.cpp

示例3: JNI_GET_PDATA

void* AwtPanel::Restack(void * param) {
    TRY;

    JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    jobjectArray peers = (jobjectArray)param;

    int peerCount = env->GetArrayLength(peers);
    if (peerCount < 1) {
        env->DeleteGlobalRef(peers);
        return AWTPANEL_RESTACK_MSG_1;
    }

    jobject self = env->GetObjectArrayElement(peers, 0);
    // It's entirely possible that our native resources have been destroyed
    // before our java peer - if we're dispose()d, for instance.
    // Alert caller w/ IllegalComponentStateException.
    if (self == NULL) {
        env->DeleteGlobalRef(peers);
        return AWTPANEL_RESTACK_MSG_2;
    }
    PDATA pData = JNI_GET_PDATA(self);
    if (pData == NULL) {
        env->DeleteGlobalRef(peers);
        env->DeleteLocalRef(self);
        return AWTPANEL_RESTACK_MSG_3;
    }

    AwtPanel* panel = (AwtPanel*)pData;

    HWND prevWindow = 0;

    for (int i = 1; i < peerCount; i++) {
        jobject peer = env->GetObjectArrayElement(peers, i);
        if (peer == NULL) {
            // Nonsense
            env->DeleteGlobalRef(peers);
            env->DeleteLocalRef(self);
            return  AWTPANEL_RESTACK_MSG_4;
        }
        PDATA child_pData = JNI_GET_PDATA(peer);
        if (child_pData == NULL) {
            env->DeleteLocalRef(peer);
            env->DeleteGlobalRef(peers);
            env->DeleteLocalRef(self);
            return AWTPANEL_RESTACK_MSG_3;
        }
        AwtComponent* child_comp = (AwtComponent*)child_pData;
        ::SetWindowPos(child_comp->GetHWnd(), prevWindow, 0, 0, 0, 0,
                       SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_DEFERERASE | SWP_ASYNCWINDOWPOS);
        prevWindow = child_comp->GetHWnd();
        env->DeleteLocalRef(peer);
    }
    env->DeleteGlobalRef(peers);
    env->DeleteLocalRef(self);

    CATCH_BAD_ALLOC_RET("Allocation error");
    return NULL;
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:58,代码来源:awt_Panel.cpp

示例4: Java_sun_awt_windows_WRobotPeer_getRGBPixelImpl

JNIEXPORT jint JNICALL Java_sun_awt_windows_WRobotPeer_getRGBPixelImpl(
    JNIEnv * env, jobject self, jint x, jint y)
{
    TRY;

    return AwtRobot::GetRobot(self)->GetRGBPixel(x, y);

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:9,代码来源:awt_Robot.cpp

示例5: Java_sun_awt_windows_WCustomCursor_getCursorHeight

/*
 * Class:     sun_awt_windows_WCustomCursor
 * Method:    getCursorHeight
 * Signature: ()I
 */
JNIEXPORT jint JNICALL
Java_sun_awt_windows_WCustomCursor_getCursorHeight(JNIEnv *, jclass)
{
    TRY;

    DTRACE_PRINTLN("WCustomCursor.getCursorHeight()");
    return (jint)::GetSystemMetrics(SM_CYCURSOR);

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:frohoff,项目名称:jdk6,代码行数:15,代码来源:awt_Cursor.cpp

示例6: Java_sun_print_Win32PrintServiceLookup_getAllPrinterNames

JNIEXPORT jobjectArray JNICALL
Java_sun_print_Win32PrintServiceLookup_getAllPrinterNames(JNIEnv *env,
                                                          jobject peer)
{
    TRY;

    DWORD cbNeeded = 0;
    DWORD cReturned = 0;
    LPBYTE pPrinterEnum = NULL;

    jstring utf_str;
    jclass clazz = env->FindClass("java/lang/String");
    if (clazz == NULL) {
        return NULL;
    }
    jobjectArray nameArray;

    try {
        ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
                       NULL, 4, NULL, 0, &cbNeeded, &cReturned);
        pPrinterEnum = new BYTE[cbNeeded];
        ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
                       NULL, 4, pPrinterEnum, cbNeeded, &cbNeeded,
                       &cReturned);

        if (cReturned > 0) {
            nameArray = env->NewObjectArray(cReturned, clazz, NULL);
            if (nameArray == NULL) {
                throw std::bad_alloc();
            }
        } else {
            nameArray = NULL;
        }


        for (DWORD i = 0; i < cReturned; i++) {
            PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
                (pPrinterEnum + i * sizeof(PRINTER_INFO_4));
            utf_str = JNU_NewStringPlatform(env, info4->pPrinterName);
            if (utf_str == NULL) {
                throw std::bad_alloc();
            }
            env->SetObjectArrayElement(nameArray, i, utf_str);
            env->DeleteLocalRef(utf_str);
        }
    } catch (std::bad_alloc&) {
        delete [] pPrinterEnum;
        throw;
    }

    delete [] pPrinterEnum;
    return nameArray;

    CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:55,代码来源:WPrinterJob.cpp

示例7: Java_sun_awt_windows_WScrollPanePeer__1getVScrollbarWidth

/*
 * Class:     sun_awt_windows_WScrollPanePeer
 * Method:    _getVScrollbarWidth
 * Signature: ()I
 */
JNIEXPORT jint JNICALL
Java_sun_awt_windows_WScrollPanePeer__1getVScrollbarWidth(JNIEnv *env,
                                                          jobject self)
{
    TRY;

    DTRACE_PRINTLN1("%x: WScrollPanePeer._getVScrollbarHeight()", self);
    return ::GetSystemMetrics(SM_CXVSCROLL);

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:16,代码来源:awt_ScrollPane.cpp

示例8: Java_sun_awt_windows_WGlobalCursorManager_getLocationOnScreen

/*
 * Class:     sun_awt_windows_WGlobalCursorManager
 * Method:    getLocationOnScreen
 * Signature: (L/java/awt/Component;)L/java/awt/Point
 */
JNIEXPORT jobject JNICALL
Java_sun_awt_windows_WGlobalCursorManager_getLocationOnScreen(
    JNIEnv *env, jobject, jobject component)
{
    TRY;

    JNI_CHECK_NULL_RETURN_NULL(component, "null component");
    jobject point =
        env->CallObjectMethod(component, AwtComponent::getLocationOnScreenMID);
    return point;

    CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:frohoff,项目名称:jdk6,代码行数:18,代码来源:awt_Cursor.cpp

示例9: Java_sun_awt_windows_WTextComponentPeer_getSelectionEnd

    /*
     * Class:     sun_awt_windows_WTextComponentPeer
     * Method:    getSelectionEnd
     * Signature: ()I
     */
    JNIEXPORT jint JNICALL
    Java_sun_awt_windows_WTextComponentPeer_getSelectionEnd(JNIEnv *env,
            jobject self)
    {
        TRY;

        return static_cast<jint>(reinterpret_cast<INT_PTR>(AwtToolkit::GetInstance().SyncCall(
                                     (void *(*)(void *))AwtTextComponent::_GetSelectionEnd,
                                     env->NewGlobalRef(self))));
        // global ref is deleted in _GetSelectionEnd()

        CATCH_BAD_ALLOC_RET(0);
    }
开发者ID:sakeinntojiu,项目名称:openjdk8-jdk,代码行数:18,代码来源:awt_TextComponent.cpp

示例10: Java_sun_print_Win32PrintService_getAllMediaSizes

JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllMediaSizes(JNIEnv *env,
                                                  jobject peer,
                                                  jstring printer,
                                                  jstring port)
{
  TRY;

  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                          printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

  jintArray mediaArray = NULL;

  SAVE_CONTROLWORD
  int nPapers = ::DeviceCapabilities(printerName, printerPort,
                                      DC_PAPERSIZE,   NULL, NULL) ;
  RESTORE_CONTROLWORD
  if (nPapers > 0) {
    mediaArray = env->NewIntArray(nPapers*2);
    if (mediaArray == NULL) {
      throw std::bad_alloc();
    }

    jboolean isCopy;
    jint *jpcIndices = env->GetIntArrayElements(mediaArray,
                                          &isCopy), *saveFormats = jpcIndices;

    LPTSTR buf = (LPTSTR)new char[nPapers * sizeof(POINT)]; // array of POINTs

    if (::DeviceCapabilities(printerName, printerPort,
                             DC_PAPERSIZE, buf, NULL) != -1) {

      POINT *pDim = (POINT *)buf;
      for (int i = 0; i < nPapers; i++) {
        jpcIndices[i*2] = (pDim+i)->x;
        jpcIndices[i*2+1] = (pDim+i)->y;
      }
    }
    RESTORE_CONTROLWORD
    delete[] buf;
    env->ReleaseIntArrayElements(mediaArray, saveFormats, 0);
  }

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, port, printerPort);
  return mediaArray;

  CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:50,代码来源:WPrinterJob.cpp

示例11: Java_sun_awt_windows_WListPeer_getMaxWidth

/*
 * Class:     sun_awt_windows_WListPeer
 * Method:    getMaxWidth
 * Signature: ()I
 */
JNIEXPORT jint JNICALL
Java_sun_awt_windows_WListPeer_getMaxWidth(JNIEnv *env, jobject self)
{
    TRY;

    jobject selfGlobalRef = env->NewGlobalRef(self);

    return (jint)AwtToolkit::GetInstance().SyncCall(
        (void *(*)(void *))AwtList::_GetMaxWidth,
        (void *)selfGlobalRef);
    // selfGlobalRef is deleted in _GetMaxWidth

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:19,代码来源:awt_List.cpp

示例12: Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName

JNIEXPORT jstring JNICALL
Java_sun_print_Win32PrintServiceLookup_getDefaultPrinterName(JNIEnv *env,
                                                             jobject peer)
{
    TRY;

    TCHAR cBuffer[250];
    OSVERSIONINFO osv;
    PRINTER_INFO_2 *ppi2 = NULL;
    DWORD dwNeeded = 0;
    DWORD dwReturned = 0;
    LPTSTR pPrinterName = NULL;
    jstring jPrinterName;

    // What version of Windows are you running?
    osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&osv);

    // If Windows 2000, XP, Vista
    if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {

       // Retrieve the default string from Win.ini (the registry).
       // String will be in form "printername,drivername,portname".

       if (GetProfileString(TEXT("windows"), TEXT("device"), TEXT(",,,"),
                            cBuffer, 250) <= 0) {
           return NULL;
       }
       // Copy printer name into passed-in buffer...
       int index = 0;
       int len = lstrlen(cBuffer);
       while ((index < len) && cBuffer[index] != _T(',')) {
              index++;
       }
       if (index==0) {
         return NULL;
       }

       pPrinterName = (LPTSTR)GlobalAlloc(GPTR, (index+1)*sizeof(TCHAR));
       lstrcpyn(pPrinterName, cBuffer, index+1);
       jPrinterName = JNU_NewStringPlatform(env, pPrinterName);
       GlobalFree(pPrinterName);
       return jPrinterName;
    } else {
        return NULL;
    }

    CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:49,代码来源:WPrinterJob.cpp

示例13: Java_sun_awt_windows_WDataTransferer_registerClipboardFormat

/*
 * Class:     sun_awt_windows_WDataTransferer
 * Method:    registerClipboardFormat
 * Signature: (Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL
Java_sun_awt_windows_WDataTransferer_registerClipboardFormat(JNIEnv *env,
                                                             jclass cls,
                                                             jstring str)
{
    TRY;

    LPCTSTR cStr = JNU_GetStringPlatformChars(env, str, NULL);
    jlong value = ::RegisterClipboardFormat(cStr);
    JNU_ReleaseStringPlatformChars(env, str, cStr);

    return value;

    CATCH_BAD_ALLOC_RET(0);
}
开发者ID:sakeinntojiu,项目名称:openjdk8-jdk,代码行数:20,代码来源:awt_DataTransferer.cpp

示例14: Java_sun_print_Win32PrintService_getAllMediaTrays

JNIEXPORT jintArray JNICALL
Java_sun_print_Win32PrintService_getAllMediaTrays(JNIEnv *env,
                                                  jobject peer,
                                                  jstring printer,
                                                  jstring port)
{
  TRY;

  LPTSTR printerName = (LPTSTR)JNU_GetStringPlatformChars(env,
                                                          printer, NULL);
  LPTSTR printerPort = (LPTSTR)JNU_GetStringPlatformChars(env, port, NULL);

  jintArray mediaTrayArray = NULL;

  SAVE_CONTROLWORD
  int nBins = ::DeviceCapabilities(printerName, printerPort,
                                   DC_BINS,   NULL, NULL) ;
  RESTORE_CONTROLWORD
  if (nBins > 0) {
    mediaTrayArray = env->NewIntArray(nBins);
    if (mediaTrayArray == NULL) {
      throw std::bad_alloc();
    }

    jboolean isCopy;
    jint *jpcIndices = env->GetIntArrayElements(mediaTrayArray,
                                           &isCopy), *saveFormats = jpcIndices;

    LPTSTR buf = (LPTSTR)new char[nBins * sizeof(WORD)];

    if (::DeviceCapabilities(printerName, printerPort,
                             DC_BINS, buf, NULL) != -1) {
      RESTORE_CONTROLWORD
      WORD *pBins = (WORD *)buf;
      for (int i = 0; i < nBins; i++) {
        jpcIndices[i] = *(pBins+i);
      }
    }
    delete[] buf;
    env->ReleaseIntArrayElements(mediaTrayArray, saveFormats, 0);
  }

  JNU_ReleaseStringPlatformChars(env, printer, printerName);
  JNU_ReleaseStringPlatformChars(env, port, printerPort);
  return mediaTrayArray;

  CATCH_BAD_ALLOC_RET(NULL);
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:48,代码来源:WPrinterJob.cpp

示例15: Java_sun_awt_windows_WListPeer_isSelected

/*
 * Class:     sun_awt_windows_WListPeer
 * Method:    isSelected
 * Signature: (I)Z
 */
JNIEXPORT jboolean JNICALL
Java_sun_awt_windows_WListPeer_isSelected(JNIEnv *env, jobject self,
                                          jint index)
{
    TRY;

    SelectElementStruct *ses = new SelectElementStruct;
    ses->list = env->NewGlobalRef(self);
    ses->index = index;

    return (jboolean)AwtToolkit::GetInstance().SyncCall(
        (void *(*)(void *))AwtList::_IsSelected, ses);
    // global ref and ses are deleted in _IsSelected

    CATCH_BAD_ALLOC_RET(FALSE);
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:21,代码来源:awt_List.cpp


注:本文中的CATCH_BAD_ALLOC_RET函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。