Audiovox P965 Datenblatt Seite 232

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 280
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 231
API in C
229
}
/********************************************************************
* Add a sentence to a block
* Allocate memory and add a sentence to a Block.
********************************************************************/
void addSentenceToBlock(struct Block *stBlock, struct Sentence *stSentence)
{
int iNewLength;
iNewLength = stBlock->iLength + 1;
DEBUG ? printf("addSentenceToBlock iNewLength=%d\n", iNewLength) : 0;
// allocate mem for the new Sentence position
if (stBlock->iLength == 0)
{
stBlock->stSentence = malloc(1 * sizeof stBlock->stSentence);
}
else
{
stBlock->stSentence = realloc(stBlock->stSentence, iNewLength * sizeof stBlock->stSentence + 1);
}
// allocate mem for the full sentence struct
stBlock->stSentence[stBlock->iLength] = malloc(sizeof *stSentence);
// copy actual sentence struct to the block position
memcpy(stBlock->stSentence[stBlock->iLength], stSentence, sizeof *stSentence);
// update iLength
stBlock->iLength = iNewLength;
DEBUG ? printf("addSentenceToBlock stBlock->iLength=%d\n", stBlock->iLength) : 0;
}
/********************************************************************
* Initialize a new sentence
********************************************************************/
void initializeSentence(struct Sentence *stSentence)
{
DEBUG ? printf("initializeSentence\n") : 0;
Seitenansicht 231
1 2 ... 227 228 229 230 231 232 233 234 235 236 237 ... 279 280

Kommentare zu diesen Handbüchern

Keine Kommentare