Home | History | Annotate | Download | only in jdwp
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 /*
     17  * Expanding byte buffer, with primitives for appending basic data types.
     18  */
     19 #ifndef DALVIK_JDWP_EXPANDBUF_H_
     20 #define DALVIK_JDWP_EXPANDBUF_H_
     21 
     22 #include "Common.h"     // need u1/u2/u4/u8 types
     23 
     24 struct ExpandBuf;   /* private */
     25 
     26 /* create a new struct */
     27 ExpandBuf* expandBufAlloc(void);
     28 /* free storage */
     29 void expandBufFree(ExpandBuf* pBuf);
     30 
     31 /*
     32  * Accessors.  The buffer pointer and length will only be valid until more
     33  * data is added.
     34  */
     35 u1* expandBufGetBuffer(ExpandBuf* pBuf);
     36 size_t expandBufGetLength(ExpandBuf* pBuf);
     37 
     38 /*
     39  * The "add" operations allocate additional storage and append the data.
     40  *
     41  * There are no "get" operations included with this "class", other than
     42  * GetBuffer().  If you want to get or set data from a position other
     43  * than the end, get a pointer to the buffer and use the inline functions
     44  * defined elsewhere.
     45  *
     46  * expandBufAddSpace() returns a pointer to the *start* of the region
     47  * added.
     48  */
     49 u1* expandBufAddSpace(ExpandBuf* pBuf, int gapSize);
     50 void expandBufAdd1(ExpandBuf* pBuf, u1 val);
     51 void expandBufAdd2BE(ExpandBuf* pBuf, u2 val);
     52 void expandBufAdd4BE(ExpandBuf* pBuf, u4 val);
     53 void expandBufAdd8BE(ExpandBuf* pBuf, u8 val);
     54 void expandBufAddUtf8String(ExpandBuf* pBuf, const u1* str);
     55 
     56 #endif  // DALVIK_JDWP_EXPANDBUF_H_
     57