1 /* 2 * Copyright (C) 2020 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 #pragma once 18 19 #include <sys/cdefs.h> 20 21 #include <stdbool.h> 22 #include <stddef.h> 23 24 __BEGIN_DECLS 25 26 struct ExpandableString { 27 size_t dataSize; // The length of the C string data (not including the null-terminator). 28 char* data; // The C string data. 29 }; 30 31 // Initialize ExpandableString. 32 void ExpandableStringInitialize(struct ExpandableString* s); 33 34 // Release memory associated with ExpandableString. 35 void ExpandableStringRelease(struct ExpandableString* s); 36 37 // Append null-terminated string |text| to ExpandableString, expanding the storage if required. 38 // Returns true on success, false othewise. 39 bool ExpandableStringAppend(struct ExpandableString* s, const char* text); 40 41 // Assign null-terminate string |text| to ExpandableString, expanding the storage if required. 42 // Returns true on success, false othewise. 43 bool ExpandableStringAssign(struct ExpandableString*s, const char* text); 44 45 __END_DECLS 46